Skip to content

Commit

Permalink
Use Serializer::collect_seq in serialize impls (serenity-rs#2744)
Browse files Browse the repository at this point in the history
  • Loading branch information
GnomedDev committed Nov 15, 2024
1 parent f39aab7 commit 102085f
Showing 1 changed file with 1 addition and 7 deletions.
8 changes: 1 addition & 7 deletions src/model/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -377,13 +377,7 @@ pub fn serialize_map_values<K, S: Serializer, V: Serialize>(
map: &HashMap<K, V>,
serializer: S,
) -> StdResult<S::Ok, S::Error> {
let mut seq = serializer.serialize_seq(Some(map.len()))?;

for value in map.values() {
seq.serialize_element(&value)?;
}

seq.end()
serializer.collect_seq(map.values())
}

/// Deserializes a sequence and builds a `HashMap` with the key extraction function.
Expand Down

0 comments on commit 102085f

Please sign in to comment.