Skip to content
This repository has been archived by the owner on Dec 17, 2024. It is now read-only.

Commit

Permalink
Correctly forward Serializer::collect_seq and collect_map methods
Browse files Browse the repository at this point in the history
  • Loading branch information
Mingun committed Jul 28, 2024
1 parent d63de9e commit dbb1fa9
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions src/configure.rs
Original file line number Diff line number Diff line change
Expand Up @@ -334,6 +334,27 @@ macro_rules! impl_serializer {
.serialize_struct_variant(name, variant_index, variant, len)
.map($wrapper)
}

fn collect_seq<I>(self, iter: I) -> Result<Self::Ok, Self::Error>
where
I: IntoIterator,
<I as IntoIterator>::Item: Serialize,
{
self.0
.collect_seq(iter.into_iter().map(|item| $wrapper(item)))
}

fn collect_map<K, V, I>(self, iter: I) -> Result<Self::Ok, Self::Error>
where
K: Serialize,
V: Serialize,
I: IntoIterator<Item = (K, V)>,
{
self.0.collect_map(
iter.into_iter()
.map(|(key, value)| ($wrapper(key), $wrapper(value))),
)
}
}

impl<S> SerializeSeq for $wrapper<S>
Expand Down

0 comments on commit dbb1fa9

Please sign in to comment.