diff options
author | Anthony Ramine <n.oxyde@gmail.com> | 2016-10-23 11:55:16 +0200 |
---|---|---|
committer | Anthony Ramine <n.oxyde@gmail.com> | 2016-10-23 11:55:16 +0200 |
commit | 39f7d33b0b3e25da392257311ee071bcf3857d25 (patch) | |
tree | a1e5e1b8d0f5351cb1d2dc3fd07018d06a0b6427 /src/de.rs | |
parent | 7e09a773cd10461fc0d18ca15475fef62368d293 (diff) |
Use opaque structs instead of opaque tuples
Opaque struct tuples leak their arity.
Diffstat (limited to 'src/de.rs')
-rw-r--r-- | src/de.rs | 14 |
1 files changed, 8 insertions, 6 deletions
@@ -55,13 +55,15 @@ pub fn from_str<T: de::Deserialize>(input: &str) -> Result<T, Error> { /// /// * Everything else but `deserialize_seq` and `deserialize_seq_fixed_size` /// defers to `deserialize`. -pub struct Deserializer<'a>( - MapDeserializer<UrlEncodedParse<'a>, Cow<'a, str>, Cow<'a, str>, Error>); +pub struct Deserializer<'a> { + inner: + MapDeserializer<UrlEncodedParse<'a>, Cow<'a, str>, Cow<'a, str>, Error>, +} impl<'a> Deserializer<'a> { /// Returns a new `Deserializer`. pub fn new(parser: UrlEncodedParse<'a>) -> Self { - Deserializer(MapDeserializer::unbounded(parser)) + Deserializer { inner: MapDeserializer::unbounded(parser) } } } @@ -82,7 +84,7 @@ impl<'a> de::Deserializer for Deserializer<'a> -> Result<V::Value, Self::Error> where V: de::Visitor, { - visitor.visit_map(&mut self.0) + visitor.visit_map(&mut self.inner) } fn deserialize_seq<V>( @@ -90,7 +92,7 @@ impl<'a> de::Deserializer for Deserializer<'a> -> Result<V::Value, Self::Error> where V: de::Visitor, { - visitor.visit_seq(&mut self.0) + visitor.visit_seq(&mut self.inner) } fn deserialize_seq_fixed_size<V>( @@ -98,7 +100,7 @@ impl<'a> de::Deserializer for Deserializer<'a> -> Result<V::Value, Self::Error> where V: de::Visitor { - visitor.visit_seq(&mut self.0) + visitor.visit_seq(&mut self.inner) } forward_to_deserialize! { |