Skip to content

Commit

Permalink
cargo fmt
Browse files Browse the repository at this point in the history
  • Loading branch information
meithecatte committed Dec 13, 2021
1 parent 3932a01 commit 2bdcc46
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions enumflags_derive/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -151,13 +151,18 @@ fn inferred_value(type_name: &Ident, previous_variants: &[Ident], repr: &Ident)
}

fn infer_values(flags: &mut [Flag], type_name: &Ident, repr: &Ident) {
let mut previous_variants: Vec<Ident> = flags.iter()
let mut previous_variants: Vec<Ident> = flags
.iter()
.filter(|flag| !flag.value.is_inferred())
.map(|flag| flag.name.clone()).collect();
.map(|flag| flag.name.clone())
.collect();

for flag in flags {
if let FlagValue::Inferred(ref mut variant) = flag.value {
variant.discriminant = Some((<Token![=]>::default(), inferred_value(type_name, &previous_variants, repr)));
variant.discriminant = Some((
<Token![=]>::default(),
inferred_value(type_name, &previous_variants, repr),
));
previous_variants.push(flag.name.clone());
}
}
Expand Down

0 comments on commit 2bdcc46

Please sign in to comment.