From 4ad8c0b2134e44b51f7ad7c12089f8149c6299de Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakub=20K=C4=85dzio=C5=82ka?= Date: Wed, 24 Feb 2021 16:27:36 +0100 Subject: [PATCH] Clippy suggestions --- enumflags_derive/src/lib.rs | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/enumflags_derive/src/lib.rs b/enumflags_derive/src/lib.rs index 8e4c2d9..ab317f3 100644 --- a/enumflags_derive/src/lib.rs +++ b/enumflags_derive/src/lib.rs @@ -25,6 +25,8 @@ enum FlagValue<'a> { } impl FlagValue<'_> { + // matches! is beyond our MSRV + #[allow(clippy::match_like_matches_macro)] fn is_inferred(&self) -> bool { match self { FlagValue::Inferred(_) => true, @@ -148,18 +150,15 @@ fn inferred_value(type_name: &Ident, previous_variants: &[Ident], repr: &Ident) syn::parse2(tokens).expect("couldn't parse inferred value") } -fn infer_values<'a>(flags: &mut [Flag], type_name: &Ident, repr: &Ident) { +fn infer_values(flags: &mut [Flag], type_name: &Ident, repr: &Ident) { let mut previous_variants: Vec = flags.iter() .filter(|flag| !flag.value.is_inferred()) .map(|flag| flag.name.clone()).collect(); for flag in flags { - match flag.value { - FlagValue::Inferred(ref mut variant) => { - variant.discriminant = Some((::default(), inferred_value(type_name, &previous_variants, repr))); - previous_variants.push(flag.name.clone()); - } - _ => {} + if let FlagValue::Inferred(ref mut variant) = flag.value { + variant.discriminant = Some((::default(), inferred_value(type_name, &previous_variants, repr))); + previous_variants.push(flag.name.clone()); } } }