Skip to content

Commit

Permalink
style(prost-build): Use enum getter (#1238)
Browse files Browse the repository at this point in the history
Use enum getter function to compare enum values instead of `i32` values.
  • Loading branch information
caspermeijn authored Feb 7, 2025
1 parent 60abdc9 commit 61b4b95
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion prost-build/src/code_generator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -383,7 +383,7 @@ impl<'b> CodeGenerator<'_, 'b> {

fn append_field(&mut self, fq_message_name: &str, field: &Field) {
let type_ = field.descriptor.r#type();
let repeated = field.descriptor.label == Some(Label::Repeated as i32);
let repeated = field.descriptor.label() == Label::Repeated;
let deprecated = self.deprecated(&field.descriptor);
let optional = self.optional(&field.descriptor);
let boxed = self
Expand Down
2 changes: 1 addition & 1 deletion prost-build/src/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ impl<'a> Context<'a> {
oneof: Option<&str>,
field: &FieldDescriptorProto,
) -> bool {
let repeated = field.label == Some(Label::Repeated as i32);
let repeated = field.label() == Label::Repeated;
let fd_type = field.r#type();
if !repeated
&& (fd_type == Type::Message || fd_type == Type::Group)
Expand Down

0 comments on commit 61b4b95

Please sign in to comment.