Skip to content

Commit

Permalink
Simplify enumerate().find(...) -> Iterator::position
Browse files Browse the repository at this point in the history
  • Loading branch information
dtolnay committed Jun 8, 2023
1 parent 43b23c7 commit 361c23a
Showing 1 changed file with 2 additions and 6 deletions.
8 changes: 2 additions & 6 deletions serde_derive/src/de.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1168,12 +1168,8 @@ fn deserialize_enum(
cattrs: &attr::Container,
) -> Fragment {
// The variants have already been checked (in ast.rs) that all untagged variants appear at the end
match variants
.iter()
.enumerate()
.find(|(_, var)| var.attrs.untagged())
{
Some((variant_idx, _)) => {
match variants.iter().position(|var| var.attrs.untagged()) {
Some(variant_idx) => {
let (tagged, untagged) = variants.split_at(variant_idx);
let tagged_frag = Expr(deserialize_homogeneous_enum(params, tagged, cattrs));
let tagged_frag = |deserializer| {
Expand Down

0 comments on commit 361c23a

Please sign in to comment.