From 9960d5af2d853613ea8a7d26cf2d000358d09226 Mon Sep 17 00:00:00 2001 From: Anthony Ramine Date: Sat, 28 Jan 2017 17:09:10 +0100 Subject: Update to serde 0.9.0 (fixes #7) --- src/de.rs | 33 ++++++++++++--------------------- 1 file changed, 12 insertions(+), 21 deletions(-) (limited to 'src/de.rs') diff --git a/src/de.rs b/src/de.rs index 42c1f04..95208e9 100644 --- a/src/de.rs +++ b/src/de.rs @@ -4,7 +4,6 @@ use serde::de; pub use serde::de::value::Error; use serde::de::value::MapDeserializer; -use std::borrow::Cow; use url::form_urlencoded::Parse as UrlEncodedParse; use url::form_urlencoded::parse; @@ -24,7 +23,7 @@ use url::form_urlencoded::parse; /// Ok(meal)); /// ``` pub fn from_bytes(input: &[u8]) -> Result { - T::deserialize(&mut Deserializer::new(parse(input))) + T::deserialize(Deserializer::new(parse(input))) } /// Deserializes a `application/x-wwww-url-encoded` value from a `&str`. @@ -56,61 +55,52 @@ pub fn from_str(input: &str) -> Result { /// * Everything else but `deserialize_seq` and `deserialize_seq_fixed_size` /// defers to `deserialize`. pub struct Deserializer<'a> { - inner: MapDeserializer, - Cow<'a, str>, - Cow<'a, str>, - Error>, + inner: MapDeserializer, Error>, } impl<'a> Deserializer<'a> { /// Returns a new `Deserializer`. pub fn new(parser: UrlEncodedParse<'a>) -> Self { - Deserializer { inner: MapDeserializer::unbounded(parser) } + Deserializer { inner: MapDeserializer::new(parser) } } } impl<'a> de::Deserializer for Deserializer<'a> { type Error = Error; - fn deserialize(&mut self, visitor: V) -> Result + fn deserialize(self, visitor: V) -> Result where V: de::Visitor, { self.deserialize_map(visitor) } - fn deserialize_map(&mut self, - mut visitor: V) - -> Result + fn deserialize_map(self, visitor: V) -> Result where V: de::Visitor, { - visitor.visit_map(&mut self.inner) + visitor.visit_map(self.inner) } - fn deserialize_seq(&mut self, - mut visitor: V) - -> Result + fn deserialize_seq(self, visitor: V) -> Result where V: de::Visitor, { - visitor.visit_seq(&mut self.inner) + visitor.visit_seq(self.inner) } - fn deserialize_seq_fixed_size(&mut self, + fn deserialize_seq_fixed_size(self, _len: usize, - mut visitor: V) + visitor: V) -> Result where V: de::Visitor, { - visitor.visit_seq(&mut self.inner) + visitor.visit_seq(self.inner) } forward_to_deserialize! { bool - usize u8 u16 u32 u64 - isize i8 i16 i32 @@ -123,6 +113,7 @@ impl<'a> de::Deserializer for Deserializer<'a> { unit option bytes + byte_buf unit_struct newtype_struct tuple_struct -- cgit v1.2.3