Skip to content

Commit

Permalink
Fix new clippy lints
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewhickman committed Jan 13, 2025
1 parent 5d2cccf commit ed9f99e
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 10 deletions.
2 changes: 1 addition & 1 deletion prost-reflect/src/descriptor/build/names.rs
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,7 @@ impl Visitor for NameVisitor<'_> {
});
}

let allow_alias = enum_.options.as_ref().map_or(false, |o| {
let allow_alias = enum_.options.as_ref().is_some_and(|o| {
o.value.allow_alias()
|| o.value.uninterpreted_option.iter().any(|u| {
u.name.len() == 1
Expand Down
11 changes: 4 additions & 7 deletions prost-reflect/src/descriptor/build/resolve.rs
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ impl Visitor for ResolveVisitor<'_> {
let json_name: Box<str> = self.resolve_field_json_name(field, file, path).into();

let is_packed = cardinality == Cardinality::Repeated
&& kind.map_or(false, |k| k.is_packable())
&& kind.is_some_and(|k| k.is_packable())
&& (field
.options
.as_ref()
Expand All @@ -128,7 +128,7 @@ impl Visitor for ResolveVisitor<'_> {
let supports_presence = field.proto3_optional()
|| field.oneof_index.is_some()
|| (cardinality != Cardinality::Repeated
&& (kind.map_or(false, |k| k.is_message()) || syntax == Syntax::Proto2));
&& (kind.is_some_and(|k| k.is_message()) || syntax == Syntax::Proto2));

let default = kind.and_then(|kind| {
self.parse_field_default_value(kind, field.default_value.as_deref(), file, path)
Expand Down Expand Up @@ -390,7 +390,7 @@ impl Visitor for ResolveVisitor<'_> {
self.resolve_field_json_name(extension, file, path);

let is_packed = cardinality == Cardinality::Repeated
&& kind.map_or(false, |k| k.is_packable())
&& kind.is_some_and(|k| k.is_packable())
&& (extension
.options
.as_ref()
Expand Down Expand Up @@ -631,10 +631,7 @@ impl ResolveVisitor<'_> {
file: FileIndex,
path: &[i32],
) -> Option<Value> {
let default_value = match default_value {
Some(value) => value,
None => return None,
};
let default_value = default_value?;

match kind {
KindIndex::Double
Expand Down
4 changes: 2 additions & 2 deletions prost-reflect/src/dynamic/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,7 @@ impl DynamicMessage {
pub fn has_field_by_number(&self, number: u32) -> bool {
self.desc
.get_field(number)
.map_or(false, |field_desc| self.has_field(&field_desc))
.is_some_and(|field_desc| self.has_field(&field_desc))
}

/// Gets the value of the field with the given number, or the default value if it is unset.
Expand Down Expand Up @@ -346,7 +346,7 @@ impl DynamicMessage {
pub fn has_field_by_name(&self, name: &str) -> bool {
self.desc
.get_field_by_name(name)
.map_or(false, |field_desc| self.has_field(&field_desc))
.is_some_and(|field_desc| self.has_field(&field_desc))
}

/// Gets the value of the field with the given name, or the default value if it is unset.
Expand Down

0 comments on commit ed9f99e

Please sign in to comment.