Skip to content

Commit

Permalink
Change let .. else to iterator
Browse files Browse the repository at this point in the history
  • Loading branch information
voidentente committed Aug 6, 2024
1 parent 1664ad1 commit 709ff5e
Showing 1 changed file with 7 additions and 11 deletions.
18 changes: 7 additions & 11 deletions src/ser/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1344,18 +1344,14 @@ impl<'a, W: fmt::Write> ser::SerializeStruct for Compound<'a, W> {
let name = iter.next().expect(
"is always at least one, because we push one at the beginning of this function",
);
let mut field = config.meta.get_field(name);

while let Some(name) = iter.next() {
let Some(some_field) = field else { break };

let Some(fields) = some_field.fields() else {
field = None;
break;
};

field = fields.get_field(name);
}
let field = iter
.try_fold(config.meta.get_field(name), |field, name| {
field
.and_then(|field| field.fields())
.map(|fields| fields.get_field(name))
})
.flatten();

if let Some(field) = field {
let lines: Vec<_> = field
Expand Down

0 comments on commit 709ff5e

Please sign in to comment.