From 1b1c6051027cc7d6b961a6f8b3a17a3d0f0c09ca Mon Sep 17 00:00:00 2001 From: Erick Tryzelaar Date: Thu, 26 Mar 2015 07:58:26 -0700 Subject: [PATCH] Pull deserialization impls into their own file --- benches/bench_log.rs | 12 +- serde_macros/src/de.rs | 2 +- src/{de.rs => de/impls.rs} | 444 +------------------------------------ src/de/mod.rs | 436 ++++++++++++++++++++++++++++++++++++ src/json/value.rs | 4 +- 5 files changed, 455 insertions(+), 443 deletions(-) rename src/{de.rs => de/impls.rs} (56%) create mode 100644 src/de/mod.rs diff --git a/benches/bench_log.rs b/benches/bench_log.rs index e1a235ae..20f8d5ea 100644 --- a/benches/bench_log.rs +++ b/benches/bench_log.rs @@ -66,7 +66,7 @@ impl de::Deserialize for HttpProtocol { fn deserialize< S: Deserializer, >(state: &mut S) -> Result { - state.visit(de::PrimitiveVisitor::new()) + state.visit(de::impls::PrimitiveVisitor::new()) } } @@ -114,7 +114,7 @@ impl de::Deserialize for HttpMethod { fn deserialize< S: de::Deserializer, >(state: &mut S) -> Result { - state.visit(de::PrimitiveVisitor::new()) + state.visit(de::impls::PrimitiveVisitor::new()) } } @@ -155,7 +155,7 @@ impl de::Deserialize for CacheStatus { fn deserialize< S: de::Deserializer, >(state: &mut S) -> Result { - state.visit(de::PrimitiveVisitor::new()) + state.visit(de::impls::PrimitiveVisitor::new()) } } @@ -203,7 +203,7 @@ impl de::Deserialize for OriginProtocol { fn deserialize< S: de::Deserializer, >(state: &mut S) -> Result { - state.visit(de::PrimitiveVisitor::new()) + state.visit(de::impls::PrimitiveVisitor::new()) } } @@ -245,7 +245,7 @@ impl de::Deserialize for ZonePlan { fn deserialize< S: de::Deserializer, >(state: &mut S) -> Result { - state.visit(de::PrimitiveVisitor::new()) + state.visit(de::impls::PrimitiveVisitor::new()) } } @@ -538,7 +538,7 @@ impl de::Deserialize for Country { fn deserialize< S: de::Deserializer, >(state: &mut S) -> Result { - state.visit(de::PrimitiveVisitor::new()) + state.visit(de::impls::PrimitiveVisitor::new()) } } diff --git a/serde_macros/src/de.rs b/serde_macros/src/de.rs index d7e05abf..1a95722c 100644 --- a/serde_macros/src/de.rs +++ b/serde_macros/src/de.rs @@ -417,7 +417,7 @@ fn deserialize_variant( match variant.node.kind { ast::TupleVariantKind(ref args) if args.is_empty() => { quote_expr!(cx, { - try!(visitor.visit_value(::serde::de::UnitVisitor)); + try!(visitor.visit_value(::serde::de::impls::UnitVisitor)); Ok($type_ident::$variant_ident) }) } diff --git a/src/de.rs b/src/de/impls.rs similarity index 56% rename from src/de.rs rename to src/de/impls.rs index c83a78e9..bfad1e07 100644 --- a/src/de.rs +++ b/src/de/impls.rs @@ -3,440 +3,15 @@ use std::hash::Hash; use std::marker::PhantomData; use std::num::FromPrimitive; use std::path; -use std::str; -/////////////////////////////////////////////////////////////////////////////// - -pub trait Error { - fn syntax_error() -> Self; - - fn end_of_stream_error() -> Self; - - fn missing_field_error(&'static str) -> Self; -} - -/////////////////////////////////////////////////////////////////////////////// - -pub trait Deserialize { - /// Deserialize this value given this `Deserializer`. - fn deserialize(deserializer: &mut D) -> Result - where D: Deserializer; -} - -/////////////////////////////////////////////////////////////////////////////// - -/// `Deserializer` is an abstract trait that can deserialize values into a `Visitor`. -pub trait Deserializer { - type Error: Error; - - /// The `visit` method walks a visitor through a value as it is being deserialized. - fn visit(&mut self, visitor: V) -> Result - where V: Visitor; - - /// The `visit_option` method allows a `Deserialize` type to inform the `Deserializer` that - /// it's expecting an optional value. This allows deserializers that encode an optional value - /// as a nullable value to convert the null value into a `None`, and a regular value as - /// `Some(value)`. - #[inline] - fn visit_option(&mut self, visitor: V) -> Result - where V: Visitor, - { - self.visit(visitor) - } - - /// The `visit_seq` method allows a `Deserialize` type to inform the `Deserializer` that it's - /// expecting a sequence of values. This allows deserializers to parse sequences that aren't - /// tagged as sequences. - #[inline] - fn visit_seq(&mut self, visitor: V) -> Result - where V: Visitor, - { - self.visit(visitor) - } - - /// The `visit_map` method allows a `Deserialize` type to inform the `Deserializer` that it's - /// expecting a map of values. This allows deserializers to parse sequences that aren't tagged - /// as maps. - #[inline] - fn visit_map(&mut self, visitor: V) -> Result - where V: Visitor, - { - self.visit(visitor) - } - - /// The `visit_named_unit` method allows a `Deserialize` type to inform the `Deserializer` that - /// it's expecting a named unit. This allows deserializers to a named unit that aren't tagged - /// as a named unit. - #[inline] - fn visit_named_unit(&mut self, _name: &str, visitor: V) -> Result - where V: Visitor, - { - self.visit(visitor) - } - - /// The `visit_named_seq` method allows a `Deserialize` type to inform the `Deserializer` that - /// it's expecting a named sequence of values. This allows deserializers to parse sequences - /// that aren't tagged as sequences. - #[inline] - fn visit_named_seq(&mut self, _name: &str, visitor: V) -> Result - where V: Visitor, - { - self.visit_seq(visitor) - } - - /// The `visit_named_map` method allows a `Deserialize` type to inform the `Deserializer` that - /// it's expecting a map of values. This allows deserializers to parse sequences that aren't - /// tagged as maps. - #[inline] - fn visit_named_map(&mut self, _name: &str, visitor: V) -> Result - where V: Visitor, - { - self.visit_map(visitor) - } - - /// The `visit_enum` method allows a `Deserialize` type to inform the `Deserializer` that it's - /// expecting an enum value. This allows deserializers that provide a custom enumeration - /// serialization to properly deserialize the type. - #[inline] - fn visit_enum(&mut self, _enum: &str, _visitor: V) -> Result - where V: EnumVisitor, - { - Err(Error::syntax_error()) - } - - /// The `visit_bytes` method allows a `Deserialize` type to inform the `Deserializer` that it's - /// expecting a `Vec`. This allows deserializers that provide a custom byte vector - /// serialization to properly deserialize the type. - #[inline] - fn visit_bytes(&mut self, visitor: V) -> Result - where V: Visitor, - { - self.visit(visitor) - } -} - -/////////////////////////////////////////////////////////////////////////////// - -pub trait Visitor { - type Value; - - fn visit_bool(&mut self, _v: bool) -> Result - where E: Error, - { - Err(Error::syntax_error()) - } - - fn visit_isize(&mut self, v: isize) -> Result - where E: Error, - { - self.visit_i64(v as i64) - } - - fn visit_i8(&mut self, v: i8) -> Result - where E: Error, - { - self.visit_i64(v as i64) - } - - fn visit_i16(&mut self, v: i16) -> Result - where E: Error, - { - self.visit_i64(v as i64) - } - - fn visit_i32(&mut self, v: i32) -> Result - where E: Error, - { - self.visit_i64(v as i64) - } - - fn visit_i64(&mut self, _v: i64) -> Result - where E: Error, - { - Err(Error::syntax_error()) - } - - fn visit_usize(&mut self, v: usize) -> Result - where E: Error, - { - self.visit_u64(v as u64) - } - - fn visit_u8(&mut self, v: u8) -> Result - where E: Error, - { - self.visit_u64(v as u64) - } - - fn visit_u16(&mut self, v: u16) -> Result - where E: Error, - { - self.visit_u64(v as u64) - } - - fn visit_u32(&mut self, v: u32) -> Result - where E: Error, - { - self.visit_u64(v as u64) - } - - fn visit_u64(&mut self, _v: u64) -> Result - where E: Error, - { - Err(Error::syntax_error()) - } - - fn visit_f32(&mut self, v: f32) -> Result - where E: Error, - { - self.visit_f64(v as f64) - } - - fn visit_f64(&mut self, _v: f64) -> Result - where E: Error, - { - Err(Error::syntax_error()) - } - - #[inline] - fn visit_char(&mut self, v: char) -> Result - where E: Error, - { - // The unwraps in here should be safe. - let mut s = &mut [0; 4]; - let len = v.encode_utf8(s).unwrap(); - self.visit_str(str::from_utf8(&s[..len]).unwrap()) - } - - fn visit_str(&mut self, _v: &str) -> Result - where E: Error, - { - Err(Error::syntax_error()) - } - - #[inline] - fn visit_string(&mut self, v: String) -> Result - where E: Error, - { - self.visit_str(&v) - } - - fn visit_unit(&mut self) -> Result - where E: Error, - { - Err(Error::syntax_error()) - } - - #[inline] - fn visit_named_unit(&mut self, _name: &str) -> Result - where E: Error, - { - self.visit_unit() - } - - fn visit_none(&mut self) -> Result - where E: Error, - { - Err(Error::syntax_error()) - } - - fn visit_some(&mut self, _deserializer: &mut D) -> Result - where D: Deserializer, - { - Err(Error::syntax_error()) - } - - fn visit_seq(&mut self, _visitor: V) -> Result - where V: SeqVisitor, - { - Err(Error::syntax_error()) - } - - fn visit_map(&mut self, _visitor: V) -> Result - where V: MapVisitor, - { - Err(Error::syntax_error()) - } - - fn visit_bytes(&mut self, _v: &[u8]) -> Result - where E: Error, - { - Err(Error::syntax_error()) - } - - fn visit_byte_buf(&mut self, _v: Vec) -> Result - where E: Error, - { - Err(Error::syntax_error()) - } -} - -/////////////////////////////////////////////////////////////////////////////// - -pub trait SeqVisitor { - type Error: Error; - - fn visit(&mut self) -> Result, Self::Error> - where T: Deserialize; - - fn end(&mut self) -> Result<(), Self::Error>; - - #[inline] - fn size_hint(&self) -> (usize, Option) { - (0, None) - } -} - -impl<'a, V> SeqVisitor for &'a mut V where V: SeqVisitor { - type Error = V::Error; - - #[inline] - fn visit(&mut self) -> Result, V::Error> - where T: Deserialize - { - (**self).visit() - } - - #[inline] - fn end(&mut self) -> Result<(), V::Error> { - (**self).end() - } - - #[inline] - fn size_hint(&self) -> (usize, Option) { - (**self).size_hint() - } -} - -/////////////////////////////////////////////////////////////////////////////// - -pub trait MapVisitor { - type Error: Error; - - #[inline] - fn visit(&mut self) -> Result, Self::Error> - where K: Deserialize, - V: Deserialize, - { - match try!(self.visit_key()) { - Some(key) => { - let value = try!(self.visit_value()); - Ok(Some((key, value))) - } - None => Ok(None) - } - } - - fn visit_key(&mut self) -> Result, Self::Error> - where K: Deserialize; - - fn visit_value(&mut self) -> Result - where V: Deserialize; - - fn end(&mut self) -> Result<(), Self::Error>; - - #[inline] - fn size_hint(&self) -> (usize, Option) { - (0, None) - } - - fn missing_field(&mut self, field: &'static str) -> Result - where V: Deserialize, - { - Err(Error::missing_field_error(field)) - } -} - -impl<'a, V_> MapVisitor for &'a mut V_ where V_: MapVisitor { - type Error = V_::Error; - - #[inline] - fn visit(&mut self) -> Result, V_::Error> - where K: Deserialize, - V: Deserialize, - { - (**self).visit() - } - - #[inline] - fn visit_key(&mut self) -> Result, V_::Error> - where K: Deserialize - { - (**self).visit_key() - } - - #[inline] - fn visit_value(&mut self) -> Result - where V: Deserialize - { - (**self).visit_value() - } - - #[inline] - fn end(&mut self) -> Result<(), V_::Error> { - (**self).end() - } - - #[inline] - fn size_hint(&self) -> (usize, Option) { - (**self).size_hint() - } -} - -/////////////////////////////////////////////////////////////////////////////// - -pub trait EnumVisitor { - type Value; - - fn visit(&mut self, visitor: V) -> Result - where V: VariantVisitor; -} - -/////////////////////////////////////////////////////////////////////////////// - -pub trait VariantVisitor { - type Error: Error; - - fn visit_variant(&mut self) -> Result - where V: Deserialize; - - fn visit_value(&mut self, _visitor: V) -> Result - where V: Visitor; -} - -impl<'a, T> VariantVisitor for &'a mut T where T: VariantVisitor { - type Error = T::Error; - - fn visit_variant(&mut self) -> Result - where V: Deserialize - { - (**self).visit_variant() - } - - fn visit_value(&mut self, visitor: V) -> Result - where V: Visitor, - { - (**self).visit_value(visitor) - } -} - -/////////////////////////////////////////////////////////////////////////////// - -pub trait EnumSeqVisitor { - type Value; - - fn visit(&mut self, visitor: V) -> Result - where V: SeqVisitor; -} - -/////////////////////////////////////////////////////////////////////////////// - -pub trait EnumMapVisitor { - type Value; - - fn visit(&mut self, visitor: V) -> Result - where V: MapVisitor; -} +use de::{ + Deserialize, + Deserializer, + Error, + MapVisitor, + SeqVisitor, + Visitor, +}; /////////////////////////////////////////////////////////////////////////////// @@ -519,7 +94,7 @@ impl PrimitiveVisitor { impl< T: Deserialize + FromPrimitive -> self::Visitor for PrimitiveVisitor { +> Visitor for PrimitiveVisitor { type Value = T; impl_deserialize_num_method!(isize, visit_isize, from_isize); @@ -1074,3 +649,4 @@ impl Deserialize for path::PathBuf { deserializer.visit(PathBufVisitor) } } + diff --git a/src/de/mod.rs b/src/de/mod.rs new file mode 100644 index 00000000..02dc6cda --- /dev/null +++ b/src/de/mod.rs @@ -0,0 +1,436 @@ +use std::str; + +pub mod impls; + +/////////////////////////////////////////////////////////////////////////////// + +pub trait Error { + fn syntax_error() -> Self; + + fn end_of_stream_error() -> Self; + + fn missing_field_error(&'static str) -> Self; +} + +/////////////////////////////////////////////////////////////////////////////// + +pub trait Deserialize { + /// Deserialize this value given this `Deserializer`. + fn deserialize(deserializer: &mut D) -> Result + where D: Deserializer; +} + +/////////////////////////////////////////////////////////////////////////////// + +/// `Deserializer` is an abstract trait that can deserialize values into a `Visitor`. +pub trait Deserializer { + type Error: Error; + + /// The `visit` method walks a visitor through a value as it is being deserialized. + fn visit(&mut self, visitor: V) -> Result + where V: Visitor; + + /// The `visit_option` method allows a `Deserialize` type to inform the `Deserializer` that + /// it's expecting an optional value. This allows deserializers that encode an optional value + /// as a nullable value to convert the null value into a `None`, and a regular value as + /// `Some(value)`. + #[inline] + fn visit_option(&mut self, visitor: V) -> Result + where V: Visitor, + { + self.visit(visitor) + } + + /// The `visit_seq` method allows a `Deserialize` type to inform the `Deserializer` that it's + /// expecting a sequence of values. This allows deserializers to parse sequences that aren't + /// tagged as sequences. + #[inline] + fn visit_seq(&mut self, visitor: V) -> Result + where V: Visitor, + { + self.visit(visitor) + } + + /// The `visit_map` method allows a `Deserialize` type to inform the `Deserializer` that it's + /// expecting a map of values. This allows deserializers to parse sequences that aren't tagged + /// as maps. + #[inline] + fn visit_map(&mut self, visitor: V) -> Result + where V: Visitor, + { + self.visit(visitor) + } + + /// The `visit_named_unit` method allows a `Deserialize` type to inform the `Deserializer` that + /// it's expecting a named unit. This allows deserializers to a named unit that aren't tagged + /// as a named unit. + #[inline] + fn visit_named_unit(&mut self, _name: &str, visitor: V) -> Result + where V: Visitor, + { + self.visit(visitor) + } + + /// The `visit_named_seq` method allows a `Deserialize` type to inform the `Deserializer` that + /// it's expecting a named sequence of values. This allows deserializers to parse sequences + /// that aren't tagged as sequences. + #[inline] + fn visit_named_seq(&mut self, _name: &str, visitor: V) -> Result + where V: Visitor, + { + self.visit_seq(visitor) + } + + /// The `visit_named_map` method allows a `Deserialize` type to inform the `Deserializer` that + /// it's expecting a map of values. This allows deserializers to parse sequences that aren't + /// tagged as maps. + #[inline] + fn visit_named_map(&mut self, _name: &str, visitor: V) -> Result + where V: Visitor, + { + self.visit_map(visitor) + } + + /// The `visit_enum` method allows a `Deserialize` type to inform the `Deserializer` that it's + /// expecting an enum value. This allows deserializers that provide a custom enumeration + /// serialization to properly deserialize the type. + #[inline] + fn visit_enum(&mut self, _enum: &str, _visitor: V) -> Result + where V: EnumVisitor, + { + Err(Error::syntax_error()) + } + + /// The `visit_bytes` method allows a `Deserialize` type to inform the `Deserializer` that it's + /// expecting a `Vec`. This allows deserializers that provide a custom byte vector + /// serialization to properly deserialize the type. + #[inline] + fn visit_bytes(&mut self, visitor: V) -> Result + where V: Visitor, + { + self.visit(visitor) + } +} + +/////////////////////////////////////////////////////////////////////////////// + +pub trait Visitor { + type Value; + + fn visit_bool(&mut self, _v: bool) -> Result + where E: Error, + { + Err(Error::syntax_error()) + } + + fn visit_isize(&mut self, v: isize) -> Result + where E: Error, + { + self.visit_i64(v as i64) + } + + fn visit_i8(&mut self, v: i8) -> Result + where E: Error, + { + self.visit_i64(v as i64) + } + + fn visit_i16(&mut self, v: i16) -> Result + where E: Error, + { + self.visit_i64(v as i64) + } + + fn visit_i32(&mut self, v: i32) -> Result + where E: Error, + { + self.visit_i64(v as i64) + } + + fn visit_i64(&mut self, _v: i64) -> Result + where E: Error, + { + Err(Error::syntax_error()) + } + + fn visit_usize(&mut self, v: usize) -> Result + where E: Error, + { + self.visit_u64(v as u64) + } + + fn visit_u8(&mut self, v: u8) -> Result + where E: Error, + { + self.visit_u64(v as u64) + } + + fn visit_u16(&mut self, v: u16) -> Result + where E: Error, + { + self.visit_u64(v as u64) + } + + fn visit_u32(&mut self, v: u32) -> Result + where E: Error, + { + self.visit_u64(v as u64) + } + + fn visit_u64(&mut self, _v: u64) -> Result + where E: Error, + { + Err(Error::syntax_error()) + } + + fn visit_f32(&mut self, v: f32) -> Result + where E: Error, + { + self.visit_f64(v as f64) + } + + fn visit_f64(&mut self, _v: f64) -> Result + where E: Error, + { + Err(Error::syntax_error()) + } + + #[inline] + fn visit_char(&mut self, v: char) -> Result + where E: Error, + { + // The unwraps in here should be safe. + let mut s = &mut [0; 4]; + let len = v.encode_utf8(s).unwrap(); + self.visit_str(str::from_utf8(&s[..len]).unwrap()) + } + + fn visit_str(&mut self, _v: &str) -> Result + where E: Error, + { + Err(Error::syntax_error()) + } + + #[inline] + fn visit_string(&mut self, v: String) -> Result + where E: Error, + { + self.visit_str(&v) + } + + fn visit_unit(&mut self) -> Result + where E: Error, + { + Err(Error::syntax_error()) + } + + #[inline] + fn visit_named_unit(&mut self, _name: &str) -> Result + where E: Error, + { + self.visit_unit() + } + + fn visit_none(&mut self) -> Result + where E: Error, + { + Err(Error::syntax_error()) + } + + fn visit_some(&mut self, _deserializer: &mut D) -> Result + where D: Deserializer, + { + Err(Error::syntax_error()) + } + + fn visit_seq(&mut self, _visitor: V) -> Result + where V: SeqVisitor, + { + Err(Error::syntax_error()) + } + + fn visit_map(&mut self, _visitor: V) -> Result + where V: MapVisitor, + { + Err(Error::syntax_error()) + } + + fn visit_bytes(&mut self, _v: &[u8]) -> Result + where E: Error, + { + Err(Error::syntax_error()) + } + + fn visit_byte_buf(&mut self, _v: Vec) -> Result + where E: Error, + { + Err(Error::syntax_error()) + } +} + +/////////////////////////////////////////////////////////////////////////////// + +pub trait SeqVisitor { + type Error: Error; + + fn visit(&mut self) -> Result, Self::Error> + where T: Deserialize; + + fn end(&mut self) -> Result<(), Self::Error>; + + #[inline] + fn size_hint(&self) -> (usize, Option) { + (0, None) + } +} + +impl<'a, V> SeqVisitor for &'a mut V where V: SeqVisitor { + type Error = V::Error; + + #[inline] + fn visit(&mut self) -> Result, V::Error> + where T: Deserialize + { + (**self).visit() + } + + #[inline] + fn end(&mut self) -> Result<(), V::Error> { + (**self).end() + } + + #[inline] + fn size_hint(&self) -> (usize, Option) { + (**self).size_hint() + } +} + +/////////////////////////////////////////////////////////////////////////////// + +pub trait MapVisitor { + type Error: Error; + + #[inline] + fn visit(&mut self) -> Result, Self::Error> + where K: Deserialize, + V: Deserialize, + { + match try!(self.visit_key()) { + Some(key) => { + let value = try!(self.visit_value()); + Ok(Some((key, value))) + } + None => Ok(None) + } + } + + fn visit_key(&mut self) -> Result, Self::Error> + where K: Deserialize; + + fn visit_value(&mut self) -> Result + where V: Deserialize; + + fn end(&mut self) -> Result<(), Self::Error>; + + #[inline] + fn size_hint(&self) -> (usize, Option) { + (0, None) + } + + fn missing_field(&mut self, field: &'static str) -> Result + where V: Deserialize, + { + Err(Error::missing_field_error(field)) + } +} + +impl<'a, V_> MapVisitor for &'a mut V_ where V_: MapVisitor { + type Error = V_::Error; + + #[inline] + fn visit(&mut self) -> Result, V_::Error> + where K: Deserialize, + V: Deserialize, + { + (**self).visit() + } + + #[inline] + fn visit_key(&mut self) -> Result, V_::Error> + where K: Deserialize + { + (**self).visit_key() + } + + #[inline] + fn visit_value(&mut self) -> Result + where V: Deserialize + { + (**self).visit_value() + } + + #[inline] + fn end(&mut self) -> Result<(), V_::Error> { + (**self).end() + } + + #[inline] + fn size_hint(&self) -> (usize, Option) { + (**self).size_hint() + } +} + +/////////////////////////////////////////////////////////////////////////////// + +pub trait EnumVisitor { + type Value; + + fn visit(&mut self, visitor: V) -> Result + where V: VariantVisitor; +} + +/////////////////////////////////////////////////////////////////////////////// + +pub trait VariantVisitor { + type Error: Error; + + fn visit_variant(&mut self) -> Result + where V: Deserialize; + + fn visit_value(&mut self, _visitor: V) -> Result + where V: Visitor; +} + +impl<'a, T> VariantVisitor for &'a mut T where T: VariantVisitor { + type Error = T::Error; + + fn visit_variant(&mut self) -> Result + where V: Deserialize + { + (**self).visit_variant() + } + + fn visit_value(&mut self, visitor: V) -> Result + where V: Visitor, + { + (**self).visit_value(visitor) + } +} + +/////////////////////////////////////////////////////////////////////////////// + +pub trait EnumSeqVisitor { + type Value; + + fn visit(&mut self, visitor: V) -> Result + where V: SeqVisitor; +} + +/////////////////////////////////////////////////////////////////////////////// + +pub trait EnumMapVisitor { + type Value; + + fn visit(&mut self, visitor: V) -> Result + where V: MapVisitor; +} diff --git a/src/json/value.rs b/src/json/value.rs index 0f1b103b..2a150ecf 100644 --- a/src/json/value.rs +++ b/src/json/value.rs @@ -305,7 +305,7 @@ impl de::Deserialize for Value { fn visit_seq(&mut self, visitor: V) -> Result where V: de::SeqVisitor, { - let values = try!(de::VecVisitor::new().visit_seq(visitor)); + let values = try!(de::impls::VecVisitor::new().visit_seq(visitor)); Ok(Value::Array(values)) } @@ -313,7 +313,7 @@ impl de::Deserialize for Value { fn visit_map(&mut self, visitor: V) -> Result where V: de::MapVisitor, { - let values = try!(de::BTreeMapVisitor::new().visit_map(visitor)); + let values = try!(de::impls::BTreeMapVisitor::new().visit_map(visitor)); Ok(Value::Object(values)) } }