diff --git a/prost-reflect/src/descriptor/build/names.rs b/prost-reflect/src/descriptor/build/names.rs index e2fe5ffb..2332a36d 100644 --- a/prost-reflect/src/descriptor/build/names.rs +++ b/prost-reflect/src/descriptor/build/names.rs @@ -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 diff --git a/prost-reflect/src/descriptor/build/resolve.rs b/prost-reflect/src/descriptor/build/resolve.rs index 72a06537..02605e40 100644 --- a/prost-reflect/src/descriptor/build/resolve.rs +++ b/prost-reflect/src/descriptor/build/resolve.rs @@ -119,7 +119,7 @@ impl Visitor for ResolveVisitor<'_> { let json_name: Box = 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() @@ -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) @@ -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() @@ -631,10 +631,7 @@ impl ResolveVisitor<'_> { file: FileIndex, path: &[i32], ) -> Option { - let default_value = match default_value { - Some(value) => value, - None => return None, - }; + let default_value = default_value?; match kind { KindIndex::Double diff --git a/prost-reflect/src/dynamic/mod.rs b/prost-reflect/src/dynamic/mod.rs index 4fec99cb..c5fe389e 100644 --- a/prost-reflect/src/dynamic/mod.rs +++ b/prost-reflect/src/dynamic/mod.rs @@ -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. @@ -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. diff --git a/prost-reflect/src/reflect/wkt.rs b/prost-reflect/src/reflect/wkt.rs index b30cb8a1..b57ee39c 100644 --- a/prost-reflect/src/reflect/wkt.rs +++ b/prost-reflect/src/reflect/wkt.rs @@ -4567,7 +4567,9 @@ impl_reflect_message! { fn compare_parsed_and_coded_default_descriptors() { use prost::Message; - let desc = crate::descriptor::types::FileDescriptorSet::decode(expected_well_known_types().as_slice()).unwrap(); + let desc = + crate::descriptor::types::FileDescriptorSet::decode(expected_well_known_types().as_slice()) + .unwrap(); let built_in_desc = make_descriptor(); if desc != built_in_desc { @@ -4599,7 +4601,7 @@ fn compare_parsed_and_coded_default_descriptors() { #[cfg(test)] fn expected_well_known_types() -> Vec { - use protox::{Compiler, file::GoogleFileResolver}; + use protox::{file::GoogleFileResolver, Compiler}; // protox can output a FileDescriptorSet directly, but by going through bytes, this should still work // when upgrading to a newer prost-types version.