Skip to content

Commit

Permalink
Clippy
Browse files Browse the repository at this point in the history
  • Loading branch information
Nicceboy committed Nov 28, 2024
1 parent 09e0f21 commit d9e9158
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
12 changes: 6 additions & 6 deletions macros/macros_impl/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -339,7 +339,7 @@ impl Config {
}

pub fn has_explicit_tag(&self) -> bool {
self.tag.as_ref().map_or(false, |tag| tag.is_explicit())
self.tag.as_ref().is_some_and(|tag| tag.is_explicit())
}

pub fn tag_for_struct(&self, fields: &syn::Fields) -> proc_macro2::TokenStream {
Expand Down Expand Up @@ -369,7 +369,7 @@ pub(crate) fn is_option_type(ty: &syn::Type) -> bool {
.path
.segments
.last()
.map_or(false, |segment| segment.ident == "Option"),
.is_some_and(|segment| segment.ident == "Option"),
syn::Type::Reference(syn::TypeReference { elem, .. }) => is_option_type(elem),
_ => false,
}
Expand Down Expand Up @@ -496,7 +496,7 @@ impl<'config> VariantConfig<'config> {
}

pub fn has_explicit_tag(&self) -> bool {
self.tag.as_ref().map_or(false, |tag| tag.is_explicit())
self.tag.as_ref().is_some_and(|tag| tag.is_explicit())
}

pub fn decode(&self, name: &syn::Ident, context: usize) -> proc_macro2::TokenStream {
Expand Down Expand Up @@ -806,7 +806,7 @@ impl<'a> FieldConfig<'a> {
};

let encode = if self.tag.is_some() || self.container_config.automatic_tags {
if self.tag.as_ref().map_or(false, |tag| tag.is_explicit()) {
if self.tag.as_ref().is_some_and(|tag| tag.is_explicit()) {
// Note: encoder must be aware if the field is optional and present, so we should not do the presence check on this level
quote!(encoder.encode_explicit_prefix(#tag, &self.#field)?;)
} else if self.extension_addition {
Expand Down Expand Up @@ -964,7 +964,7 @@ impl<'a> FieldConfig<'a> {
} else {
match (
(self.tag.is_some() || self.container_config.automatic_tags)
.then(|| self.tag.as_ref().map_or(false, |tag| tag.is_explicit())),
.then(|| self.tag.as_ref().is_some_and(|tag| tag.is_explicit())),
self.default.as_ref().map(|path| {
path.as_ref()
.map_or(quote!(<_>::default), |path| quote!(#path))
Expand Down Expand Up @@ -1041,7 +1041,7 @@ impl<'a> FieldConfig<'a> {
if self.extension_addition {
match (
(self.tag.is_some() || self.container_config.automatic_tags)
.then(|| self.tag.as_ref().map_or(false, |tag| tag.is_explicit())),
.then(|| self.tag.as_ref().is_some_and(|tag| tag.is_explicit())),
self.default.as_ref().map(|path| {
path.as_ref()
.map_or(quote!(<_>::default), |path| quote!(#path))
Expand Down
2 changes: 1 addition & 1 deletion macros/macros_impl/src/decode.rs
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,7 @@ pub fn derive_struct_impl(
};

let decode_impl =
if !config.delegate && config.tag.as_ref().map_or(false, |tag| tag.is_explicit()) {
if !config.delegate && config.tag.as_ref().is_some_and(|tag| tag.is_explicit()) {
let tag = config.tag_for_struct(&container.fields);
map_from_inner_type(
tag,
Expand Down
2 changes: 1 addition & 1 deletion macros/macros_impl/src/encode.rs
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ pub fn derive_struct_impl(
}).map(drop)
};

if config.tag.as_ref().map_or(false, |tag| tag.is_explicit()) {
if config.tag.as_ref().is_some_and(|tag| tag.is_explicit()) {
map_to_inner_type(
config.tag.clone().unwrap(),
&name,
Expand Down

0 comments on commit d9e9158

Please sign in to comment.