Skip to content

Commit

Permalink
Get rid of temporary variable
Browse files Browse the repository at this point in the history
  • Loading branch information
Mingun committed Aug 6, 2023
1 parent b58e8ba commit 070cce0
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions serde_derive/src/de.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1237,7 +1237,12 @@ fn prepare_enum_variant_enum(
})
.collect();

let other_idx = deserialized_variants.position(|(_, variant)| variant.attrs.other());
let fallthrough = deserialized_variants
.position(|(_, variant)| variant.attrs.other())
.map(|other_idx| {
let ignore_variant = variant_names_idents[other_idx].1.clone();
quote!(_serde::__private::Ok(__Field::#ignore_variant))
});

let variants_stmt = {
let variant_names = variant_names_idents.iter().map(|(name, _, _)| name);
Expand All @@ -1247,11 +1252,6 @@ fn prepare_enum_variant_enum(
}
};

let fallthrough = other_idx.map(|other_idx| {
let ignore_variant = variant_names_idents[other_idx].1.clone();
quote!(_serde::__private::Ok(__Field::#ignore_variant))
});

let variant_visitor = Stmts(deserialize_generated_identifier(
&variant_names_idents,
cattrs,
Expand Down

0 comments on commit 070cce0

Please sign in to comment.