From 39f7d33b0b3e25da392257311ee071bcf3857d25 Mon Sep 17 00:00:00 2001 From: Anthony Ramine Date: Sun, 23 Oct 2016 11:55:16 +0200 Subject: Use opaque structs instead of opaque tuples Opaque struct tuples leak their arity. --- src/de.rs | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) (limited to 'src/de.rs') diff --git a/src/de.rs b/src/de.rs index 695547f..0f3cb78 100644 --- a/src/de.rs +++ b/src/de.rs @@ -55,13 +55,15 @@ pub fn from_str(input: &str) -> Result { /// /// * Everything else but `deserialize_seq` and `deserialize_seq_fixed_size` /// defers to `deserialize`. -pub struct Deserializer<'a>( - MapDeserializer, Cow<'a, str>, Cow<'a, str>, Error>); +pub struct Deserializer<'a> { + inner: + MapDeserializer, 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 where V: de::Visitor, { - visitor.visit_map(&mut self.0) + visitor.visit_map(&mut self.inner) } fn deserialize_seq( @@ -90,7 +92,7 @@ impl<'a> de::Deserializer for Deserializer<'a> -> Result where V: de::Visitor, { - visitor.visit_seq(&mut self.0) + visitor.visit_seq(&mut self.inner) } fn deserialize_seq_fixed_size( @@ -98,7 +100,7 @@ impl<'a> de::Deserializer for Deserializer<'a> -> Result where V: de::Visitor { - visitor.visit_seq(&mut self.0) + visitor.visit_seq(&mut self.inner) } forward_to_deserialize! { -- cgit v1.2.3