Skip to content

Commit

Permalink
Simplify manual try_fold into collect into Result
Browse files Browse the repository at this point in the history
  • Loading branch information
dtolnay committed Jul 3, 2023
1 parent 2f6658c commit 4b82670
Showing 1 changed file with 1 addition and 11 deletions.
12 changes: 1 addition & 11 deletions src/de.rs
Original file line number Diff line number Diff line change
Expand Up @@ -865,17 +865,7 @@ impl<'de> de::VariantAccess<'de> for TableEnumDeserializer<'de> {
},
)),
})
// Fold all values into a `Vec`, or return the first error.
.try_fold(Vec::with_capacity(len), |mut tuple_values, value_result| {
match value_result {
Ok(value) => {
tuple_values.push(value);
Ok(tuple_values)
}
// `Result<de::Value, Self::Error>` to `Result<Vec<_>, Self::Error>`
Err(e) => Err(e),
}
})?;
.collect::<Result<Vec<_>, _>>()?;

if tuple_values.len() == len {
de::Deserializer::deserialize_seq(
Expand Down

0 comments on commit 4b82670

Please sign in to comment.