From e77e7c4bba26a0daee7064c4c0fc54d767266c6f Mon Sep 17 00:00:00 2001 From: David Tolnay Date: Fri, 14 Apr 2017 12:50:35 -0700 Subject: [PATCH] Rename Deserializer::deserialize to deserialize_any --- serde/src/de/impls.rs | 4 +- serde/src/de/mod.rs | 16 +++---- serde/src/de/value.rs | 44 ++++++++++---------- serde/src/macros.rs | 92 ++++++++++++++++++++--------------------- serde/src/private/de.rs | 42 +++++++++---------- serde_derive/src/de.rs | 8 ++-- serde_test/src/de.rs | 26 ++++++------ 7 files changed, 116 insertions(+), 116 deletions(-) diff --git a/serde/src/de/impls.rs b/serde/src/de/impls.rs index b7ec32b1..3999f3e3 100644 --- a/serde/src/de/impls.rs +++ b/serde/src/de/impls.rs @@ -1070,7 +1070,7 @@ impl<'de> Deserialize<'de> for OsStringKind { } } - deserializer.deserialize(KindVisitor) + deserializer.deserialize_identifier(KindVisitor) } } @@ -1581,7 +1581,7 @@ where } } - deserializer.deserialize(FieldVisitor) + deserializer.deserialize_identifier(FieldVisitor) } } diff --git a/serde/src/de/mod.rs b/serde/src/de/mod.rs index 86398eb3..dc67021b 100644 --- a/serde/src/de/mod.rs +++ b/serde/src/de/mod.rs @@ -763,22 +763,22 @@ where /// to look at the serialized data and tell what it represents. For example /// the JSON deserializer may see an opening curly brace (`{`) and know that /// it is seeing a map. If the data format supports -/// `Deserializer::deserialize`, it will drive the Visitor using whatever +/// `Deserializer::deserialize_any`, it will drive the Visitor using whatever /// type it sees in the input. JSON uses this approach when deserializing /// `serde_json::Value` which is an enum that can represent any JSON /// document. Without knowing what is in a JSON document, we can deserialize -/// it to `serde_json::Value` by going through `Deserializer::deserialize`. +/// it to `serde_json::Value` by going through `Deserializer::deserialize_any`. /// /// 2. The various `deserialize_*` methods. Non-self-describing formats like /// Bincode need to be told what is in the input in order to deserialize it. /// The `deserialize_*` methods are hints to the deserializer for how to /// interpret the next piece of input. Non-self-describing formats are not /// able to deserialize something like `serde_json::Value` which relies on -/// `Deserializer::deserialize`. +/// `Deserializer::deserialize_any`. /// /// When implementing `Deserialize`, you should avoid relying on -/// `Deserializer::deserialize` unless you need to be told by the Deserializer -/// what type is in the input. Know that relying on `Deserializer::deserialize` +/// `Deserializer::deserialize_any` unless you need to be told by the Deserializer +/// what type is in the input. Know that relying on `Deserializer::deserialize_any` /// means your data type will be able to deserialize from self-describing /// formats only, ruling out Bincode and many others. pub trait Deserializer<'de>: Sized { @@ -790,12 +790,12 @@ pub trait Deserializer<'de>: Sized { /// on what data type is in the input. /// /// When implementing `Deserialize`, you should avoid relying on - /// `Deserializer::deserialize` unless you need to be told by the + /// `Deserializer::deserialize_any` unless you need to be told by the /// Deserializer what type is in the input. Know that relying on - /// `Deserializer::deserialize` means your data type will be able to + /// `Deserializer::deserialize_any` means your data type will be able to /// deserialize from self-describing formats only, ruling out Bincode and /// many others. - fn deserialize(self, visitor: V) -> Result + fn deserialize_any(self, visitor: V) -> Result where V: Visitor<'de>; diff --git a/serde/src/de/value.rs b/serde/src/de/value.rs index 0917d549..a521c9a6 100644 --- a/serde/src/de/value.rs +++ b/serde/src/de/value.rs @@ -88,13 +88,13 @@ where { type Error = E; - forward_to_deserialize! { + forward_to_deserialize_any! { bool u8 u16 u32 u64 i8 i16 i32 i64 f32 f64 char str string unit seq seq_fixed_size bytes map unit_struct newtype_struct tuple_struct struct identifier tuple enum ignored_any byte_buf } - fn deserialize(self, visitor: V) -> Result + fn deserialize_any(self, visitor: V) -> Result where V: de::Visitor<'de>, { @@ -140,13 +140,13 @@ macro_rules! primitive_deserializer { { type Error = E; - forward_to_deserialize! { + forward_to_deserialize_any! { bool u8 u16 u32 u64 i8 i16 i32 i64 f32 f64 char str string unit option seq seq_fixed_size bytes map unit_struct newtype_struct tuple_struct struct identifier tuple enum ignored_any byte_buf } - fn deserialize(self, visitor: V) -> Result + fn deserialize_any(self, visitor: V) -> Result where V: de::Visitor<'de>, { @@ -197,13 +197,13 @@ where { type Error = E; - forward_to_deserialize! { + forward_to_deserialize_any! { bool u8 u16 u32 u64 i8 i16 i32 i64 f32 f64 char str string unit option seq seq_fixed_size bytes map unit_struct newtype_struct tuple_struct struct identifier tuple ignored_any byte_buf } - fn deserialize(self, visitor: V) -> Result + fn deserialize_any(self, visitor: V) -> Result where V: de::Visitor<'de>, { @@ -267,7 +267,7 @@ where { type Error = E; - fn deserialize(self, visitor: V) -> Result + fn deserialize_any(self, visitor: V) -> Result where V: de::Visitor<'de>, { @@ -286,7 +286,7 @@ where visitor.visit_enum(self) } - forward_to_deserialize! { + forward_to_deserialize_any! { bool u8 u16 u32 u64 i8 i16 i32 i64 f32 f64 char str string unit option seq seq_fixed_size bytes map unit_struct newtype_struct tuple_struct struct identifier tuple ignored_any byte_buf @@ -340,7 +340,7 @@ where { type Error = E; - fn deserialize(self, visitor: V) -> Result + fn deserialize_any(self, visitor: V) -> Result where V: de::Visitor<'de>, { @@ -359,7 +359,7 @@ where visitor.visit_enum(self) } - forward_to_deserialize! { + forward_to_deserialize_any! { bool u8 u16 u32 u64 i8 i16 i32 i64 f32 f64 char str string unit option seq seq_fixed_size bytes map unit_struct newtype_struct tuple_struct struct identifier tuple ignored_any byte_buf @@ -414,7 +414,7 @@ where { type Error = E; - fn deserialize(self, visitor: V) -> Result + fn deserialize_any(self, visitor: V) -> Result where V: de::Visitor<'de>, { @@ -436,7 +436,7 @@ where visitor.visit_enum(self) } - forward_to_deserialize! { + forward_to_deserialize_any! { bool u8 u16 u32 u64 i8 i16 i32 i64 f32 f64 char str string unit option seq seq_fixed_size bytes map unit_struct newtype_struct tuple_struct struct identifier tuple ignored_any byte_buf @@ -508,7 +508,7 @@ where { type Error = E; - fn deserialize(mut self, visitor: V) -> Result + fn deserialize_any(mut self, visitor: V) -> Result where V: de::Visitor<'de>, { @@ -517,7 +517,7 @@ where Ok(v) } - forward_to_deserialize! { + forward_to_deserialize_any! { bool u8 u16 u32 u64 i8 i16 i32 i64 f32 f64 char str string unit option seq seq_fixed_size bytes map unit_struct newtype_struct tuple_struct struct identifier tuple enum ignored_any byte_buf @@ -624,14 +624,14 @@ where { type Error = V_::Error; - fn deserialize(self, visitor: V) -> Result + fn deserialize_any(self, visitor: V) -> Result where V: de::Visitor<'de>, { visitor.visit_seq(self.visitor) } - forward_to_deserialize! { + forward_to_deserialize_any! { bool u8 u16 u32 u64 i8 i16 i32 i64 f32 f64 char str string unit option seq seq_fixed_size bytes map unit_struct newtype_struct tuple_struct struct identifier tuple enum ignored_any byte_buf @@ -712,7 +712,7 @@ where { type Error = E; - fn deserialize(mut self, visitor: V_) -> Result + fn deserialize_any(mut self, visitor: V_) -> Result where V_: de::Visitor<'de>, { @@ -740,7 +740,7 @@ where self.deserialize_seq(visitor) } - forward_to_deserialize! { + forward_to_deserialize_any! { bool u8 u16 u32 u64 i8 i16 i32 i64 f32 f64 char str string unit option bytes map unit_struct newtype_struct tuple_struct struct identifier tuple enum ignored_any byte_buf @@ -888,13 +888,13 @@ where { type Error = E; - forward_to_deserialize! { + forward_to_deserialize_any! { bool u8 u16 u32 u64 i8 i16 i32 i64 f32 f64 char str string unit option bytes map unit_struct newtype_struct tuple_struct struct identifier tuple enum ignored_any byte_buf } - fn deserialize(self, visitor: V) -> Result + fn deserialize_any(self, visitor: V) -> Result where V: de::Visitor<'de>, { @@ -1029,14 +1029,14 @@ where { type Error = V_::Error; - fn deserialize(self, visitor: V) -> Result + fn deserialize_any(self, visitor: V) -> Result where V: de::Visitor<'de>, { visitor.visit_map(self.visitor) } - forward_to_deserialize! { + forward_to_deserialize_any! { bool u8 u16 u32 u64 i8 i16 i32 i64 f32 f64 char str string unit option seq seq_fixed_size bytes map unit_struct newtype_struct tuple_struct struct identifier tuple enum ignored_any byte_buf diff --git a/serde/src/macros.rs b/serde/src/macros.rs index f75eebf9..6b7ea6e2 100644 --- a/serde/src/macros.rs +++ b/serde/src/macros.rs @@ -30,7 +30,7 @@ /// # impl<'de> Deserializer<'de> for MyDeserializer { /// # type Error = value::Error; /// # -/// # fn deserialize(self, _: V) -> Result +/// # fn deserialize_any(self, _: V) -> Result /// # where V: Visitor<'de> /// # { /// # unimplemented!() @@ -40,10 +40,10 @@ /// fn deserialize_bool(self, visitor: V) -> Result /// where V: Visitor<'de> /// { -/// self.deserialize(visitor) +/// self.deserialize_any(visitor) /// } /// # -/// # forward_to_deserialize! { +/// # forward_to_deserialize_any! { /// # u8 u16 u32 u64 i8 i16 i32 i64 f32 f64 char str string unit option /// # seq seq_fixed_size bytes byte_buf map unit_struct newtype_struct /// # tuple_struct struct identifier tuple enum ignored_any @@ -53,9 +53,9 @@ /// # fn main() {} /// ``` /// -/// The `forward_to_deserialize!` macro implements these simple forwarding -/// methods so that they forward directly to [`Deserializer::deserialize`]. You -/// can choose which methods to forward. +/// The `forward_to_deserialize_any!` macro implements these simple forwarding +/// methods so that they forward directly to [`Deserializer::deserialize_any`]. +/// You can choose which methods to forward. /// /// ```rust /// # #[macro_use] @@ -68,7 +68,7 @@ /// impl<'de> Deserializer<'de> for MyDeserializer { /// # type Error = value::Error; /// # -/// fn deserialize(self, visitor: V) -> Result +/// fn deserialize_any(self, visitor: V) -> Result /// where V: Visitor<'de> /// { /// /* ... */ @@ -76,7 +76,7 @@ /// # unimplemented!() /// } /// -/// forward_to_deserialize! { +/// forward_to_deserialize_any! { /// bool u8 u16 u32 u64 i8 i16 i32 i64 f32 f64 char str string unit option /// seq seq_fixed_size bytes byte_buf map unit_struct newtype_struct /// tuple_struct struct identifier tuple enum ignored_any @@ -104,13 +104,13 @@ /// # impl<'q, V> Deserializer<'q> for MyDeserializer { /// # type Error = value::Error; /// # -/// # fn deserialize(self, visitor: W) -> Result +/// # fn deserialize_any(self, visitor: W) -> Result /// # where W: Visitor<'q> /// # { /// # unimplemented!() /// # } /// # -/// forward_to_deserialize! { +/// forward_to_deserialize_any! { /// > /// bool u8 u16 u32 u64 i8 i16 i32 i64 f32 f64 char str string unit option /// seq seq_fixed_size bytes byte_buf map unit_struct newtype_struct @@ -123,21 +123,21 @@ /// /// [`Deserializer`]: trait.Deserializer.html /// [`Visitor`]: de/trait.Visitor.html -/// [`Deserializer::deserialize`]: trait.Deserializer.html#tymethod.deserialize +/// [`Deserializer::deserialize_any`]: trait.Deserializer.html#tymethod.deserialize_any #[macro_export] -macro_rules! forward_to_deserialize { +macro_rules! forward_to_deserialize_any { (<$visitor:ident: Visitor<$lifetime:tt>> $($func:ident)*) => { - $(forward_to_deserialize_helper!{$func<$lifetime, $visitor>})* + $(forward_to_deserialize_any_helper!{$func<$lifetime, $visitor>})* }; // This case must be after the previous one. ($($func:ident)*) => { - $(forward_to_deserialize_helper!{$func<'de, V>})* + $(forward_to_deserialize_any_helper!{$func<'de, V>})* }; } #[doc(hidden)] #[macro_export] -macro_rules! forward_to_deserialize_method { +macro_rules! forward_to_deserialize_any_method { ($func:ident<$l:tt, $v:ident>($($arg:ident : $ty:ty),*)) => { #[inline] fn $func<$v>(self, $($arg: $ty,)* visitor: $v) -> $crate::export::Result<$v::Value, Self::Error> @@ -147,99 +147,99 @@ macro_rules! forward_to_deserialize_method { $( let _ = $arg; )* - self.deserialize(visitor) + self.deserialize_any(visitor) } }; } #[doc(hidden)] #[macro_export] -macro_rules! forward_to_deserialize_helper { +macro_rules! forward_to_deserialize_any_helper { (bool<$l:tt, $v:ident>) => { - forward_to_deserialize_method!{deserialize_bool<$l, $v>()} + forward_to_deserialize_any_method!{deserialize_bool<$l, $v>()} }; (u8<$l:tt, $v:ident>) => { - forward_to_deserialize_method!{deserialize_u8<$l, $v>()} + forward_to_deserialize_any_method!{deserialize_u8<$l, $v>()} }; (u16<$l:tt, $v:ident>) => { - forward_to_deserialize_method!{deserialize_u16<$l, $v>()} + forward_to_deserialize_any_method!{deserialize_u16<$l, $v>()} }; (u32<$l:tt, $v:ident>) => { - forward_to_deserialize_method!{deserialize_u32<$l, $v>()} + forward_to_deserialize_any_method!{deserialize_u32<$l, $v>()} }; (u64<$l:tt, $v:ident>) => { - forward_to_deserialize_method!{deserialize_u64<$l, $v>()} + forward_to_deserialize_any_method!{deserialize_u64<$l, $v>()} }; (i8<$l:tt, $v:ident>) => { - forward_to_deserialize_method!{deserialize_i8<$l, $v>()} + forward_to_deserialize_any_method!{deserialize_i8<$l, $v>()} }; (i16<$l:tt, $v:ident>) => { - forward_to_deserialize_method!{deserialize_i16<$l, $v>()} + forward_to_deserialize_any_method!{deserialize_i16<$l, $v>()} }; (i32<$l:tt, $v:ident>) => { - forward_to_deserialize_method!{deserialize_i32<$l, $v>()} + forward_to_deserialize_any_method!{deserialize_i32<$l, $v>()} }; (i64<$l:tt, $v:ident>) => { - forward_to_deserialize_method!{deserialize_i64<$l, $v>()} + forward_to_deserialize_any_method!{deserialize_i64<$l, $v>()} }; (f32<$l:tt, $v:ident>) => { - forward_to_deserialize_method!{deserialize_f32<$l, $v>()} + forward_to_deserialize_any_method!{deserialize_f32<$l, $v>()} }; (f64<$l:tt, $v:ident>) => { - forward_to_deserialize_method!{deserialize_f64<$l, $v>()} + forward_to_deserialize_any_method!{deserialize_f64<$l, $v>()} }; (char<$l:tt, $v:ident>) => { - forward_to_deserialize_method!{deserialize_char<$l, $v>()} + forward_to_deserialize_any_method!{deserialize_char<$l, $v>()} }; (str<$l:tt, $v:ident>) => { - forward_to_deserialize_method!{deserialize_str<$l, $v>()} + forward_to_deserialize_any_method!{deserialize_str<$l, $v>()} }; (string<$l:tt, $v:ident>) => { - forward_to_deserialize_method!{deserialize_string<$l, $v>()} + forward_to_deserialize_any_method!{deserialize_string<$l, $v>()} }; (unit<$l:tt, $v:ident>) => { - forward_to_deserialize_method!{deserialize_unit<$l, $v>()} + forward_to_deserialize_any_method!{deserialize_unit<$l, $v>()} }; (option<$l:tt, $v:ident>) => { - forward_to_deserialize_method!{deserialize_option<$l, $v>()} + forward_to_deserialize_any_method!{deserialize_option<$l, $v>()} }; (seq<$l:tt, $v:ident>) => { - forward_to_deserialize_method!{deserialize_seq<$l, $v>()} + forward_to_deserialize_any_method!{deserialize_seq<$l, $v>()} }; (seq_fixed_size<$l:tt, $v:ident>) => { - forward_to_deserialize_method!{deserialize_seq_fixed_size<$l, $v>(len: usize)} + forward_to_deserialize_any_method!{deserialize_seq_fixed_size<$l, $v>(len: usize)} }; (bytes<$l:tt, $v:ident>) => { - forward_to_deserialize_method!{deserialize_bytes<$l, $v>()} + forward_to_deserialize_any_method!{deserialize_bytes<$l, $v>()} }; (byte_buf<$l:tt, $v:ident>) => { - forward_to_deserialize_method!{deserialize_byte_buf<$l, $v>()} + forward_to_deserialize_any_method!{deserialize_byte_buf<$l, $v>()} }; (map<$l:tt, $v:ident>) => { - forward_to_deserialize_method!{deserialize_map<$l, $v>()} + forward_to_deserialize_any_method!{deserialize_map<$l, $v>()} }; (unit_struct<$l:tt, $v:ident>) => { - forward_to_deserialize_method!{deserialize_unit_struct<$l, $v>(name: &'static str)} + forward_to_deserialize_any_method!{deserialize_unit_struct<$l, $v>(name: &'static str)} }; (newtype_struct<$l:tt, $v:ident>) => { - forward_to_deserialize_method!{deserialize_newtype_struct<$l, $v>(name: &'static str)} + forward_to_deserialize_any_method!{deserialize_newtype_struct<$l, $v>(name: &'static str)} }; (tuple_struct<$l:tt, $v:ident>) => { - forward_to_deserialize_method!{deserialize_tuple_struct<$l, $v>(name: &'static str, len: usize)} + forward_to_deserialize_any_method!{deserialize_tuple_struct<$l, $v>(name: &'static str, len: usize)} }; (struct<$l:tt, $v:ident>) => { - forward_to_deserialize_method!{deserialize_struct<$l, $v>(name: &'static str, fields: &'static [&'static str])} + forward_to_deserialize_any_method!{deserialize_struct<$l, $v>(name: &'static str, fields: &'static [&'static str])} }; (identifier<$l:tt, $v:ident>) => { - forward_to_deserialize_method!{deserialize_identifier<$l, $v>()} + forward_to_deserialize_any_method!{deserialize_identifier<$l, $v>()} }; (tuple<$l:tt, $v:ident>) => { - forward_to_deserialize_method!{deserialize_tuple<$l, $v>(len: usize)} + forward_to_deserialize_any_method!{deserialize_tuple<$l, $v>(len: usize)} }; (enum<$l:tt, $v:ident>) => { - forward_to_deserialize_method!{deserialize_enum<$l, $v>(name: &'static str, variants: &'static [&'static str])} + forward_to_deserialize_any_method!{deserialize_enum<$l, $v>(name: &'static str, variants: &'static [&'static str])} }; (ignored_any<$l:tt, $v:ident>) => { - forward_to_deserialize_method!{deserialize_ignored_any<$l, $v>()} + forward_to_deserialize_any_method!{deserialize_ignored_any<$l, $v>()} }; } diff --git a/serde/src/private/de.rs b/serde/src/private/de.rs index d5c03061..7ad86def 100644 --- a/serde/src/private/de.rs +++ b/serde/src/private/de.rs @@ -33,7 +33,7 @@ where { type Error = E; - fn deserialize(self, _visitor: V) -> Result + fn deserialize_any(self, _visitor: V) -> Result where V: Visitor<'de>, { @@ -47,7 +47,7 @@ where visitor.visit_none() } - forward_to_deserialize! { + forward_to_deserialize_any! { bool u8 u16 u32 u64 i8 i16 i32 i64 f32 f64 char str string unit seq seq_fixed_size bytes byte_buf map unit_struct newtype_struct tuple_struct struct identifier tuple enum ignored_any @@ -271,7 +271,7 @@ mod content { { // Untagged and internally tagged enums are only supported in // self-describing formats. - deserializer.deserialize(ContentVisitor) + deserializer.deserialize_any(ContentVisitor) } } @@ -481,7 +481,7 @@ mod content { { // Internally tagged enums are only supported in self-describing // formats. - deserializer.deserialize(self) + deserializer.deserialize_any(self) } } @@ -745,7 +745,7 @@ mod content { { // Internally tagged enums are only supported in self-describing // formats. - deserializer.deserialize(self) + deserializer.deserialize_any(self) } } @@ -854,7 +854,7 @@ mod content { { type Error = E; - fn deserialize(self, visitor: V) -> Result + fn deserialize_any(self, visitor: V) -> Result where V: Visitor<'de>, { @@ -969,7 +969,7 @@ mod content { ) } - forward_to_deserialize! { + forward_to_deserialize_any! { bool u8 u16 u32 u64 i8 i16 i32 i64 f32 f64 char str string unit seq seq_fixed_size bytes byte_buf map unit_struct tuple_struct struct identifier tuple ignored_any @@ -1057,7 +1057,7 @@ mod content { { match self.value { Some(Content::Seq(v)) => { - de::Deserializer::deserialize(SeqDeserializer::new(v), visitor) + de::Deserializer::deserialize_any(SeqDeserializer::new(v), visitor) } Some(other) => Err(de::Error::invalid_type(other.unexpected(), &"tuple variant"),), None => Err(de::Error::invalid_type(de::Unexpected::UnitVariant, &"tuple variant"),), @@ -1074,7 +1074,7 @@ mod content { { match self.value { Some(Content::Map(v)) => { - de::Deserializer::deserialize(MapDeserializer::new(v), visitor) + de::Deserializer::deserialize_any(MapDeserializer::new(v), visitor) } Some(other) => Err(de::Error::invalid_type(other.unexpected(), &"struct variant"),), _ => Err(de::Error::invalid_type(de::Unexpected::UnitVariant, &"struct variant"),), @@ -1109,7 +1109,7 @@ mod content { type Error = E; #[inline] - fn deserialize(mut self, visitor: V) -> Result + fn deserialize_any(mut self, visitor: V) -> Result where V: de::Visitor<'de>, { @@ -1127,7 +1127,7 @@ mod content { } } - forward_to_deserialize! { + forward_to_deserialize_any! { bool u8 u16 u32 u64 i8 i16 i32 i64 f32 f64 char str string unit option seq seq_fixed_size bytes byte_buf map unit_struct newtype_struct tuple_struct struct identifier tuple enum ignored_any @@ -1221,14 +1221,14 @@ mod content { type Error = E; #[inline] - fn deserialize(self, visitor: V) -> Result + fn deserialize_any(self, visitor: V) -> Result where V: de::Visitor<'de>, { visitor.visit_map(self) } - forward_to_deserialize! { + forward_to_deserialize_any! { bool u8 u16 u32 u64 i8 i16 i32 i64 f32 f64 char str string unit option seq seq_fixed_size bytes byte_buf map unit_struct newtype_struct tuple_struct struct identifier tuple enum ignored_any @@ -1250,7 +1250,7 @@ mod content { { type Error = E; - fn deserialize(self, visitor: V) -> Result + fn deserialize_any(self, visitor: V) -> Result where V: Visitor<'de>, { @@ -1365,7 +1365,7 @@ mod content { ) } - forward_to_deserialize! { + forward_to_deserialize_any! { bool u8 u16 u32 u64 i8 i16 i32 i64 f32 f64 char str string unit seq seq_fixed_size bytes byte_buf map unit_struct tuple_struct struct identifier tuple ignored_any @@ -1450,7 +1450,7 @@ mod content { { match self.value { Some(&Content::Seq(ref v)) => { - de::Deserializer::deserialize(SeqRefDeserializer::new(v), visitor) + de::Deserializer::deserialize_any(SeqRefDeserializer::new(v), visitor) } Some(other) => Err(de::Error::invalid_type(other.unexpected(), &"tuple variant"),), None => Err(de::Error::invalid_type(de::Unexpected::UnitVariant, &"tuple variant"),), @@ -1467,7 +1467,7 @@ mod content { { match self.value { Some(&Content::Map(ref v)) => { - de::Deserializer::deserialize(MapRefDeserializer::new(v), visitor) + de::Deserializer::deserialize_any(MapRefDeserializer::new(v), visitor) } Some(other) => Err(de::Error::invalid_type(other.unexpected(), &"struct variant"),), _ => Err(de::Error::invalid_type(de::Unexpected::UnitVariant, &"struct variant"),), @@ -1502,7 +1502,7 @@ mod content { type Error = E; #[inline] - fn deserialize(mut self, visitor: V) -> Result + fn deserialize_any(mut self, visitor: V) -> Result where V: de::Visitor<'de>, { @@ -1520,7 +1520,7 @@ mod content { } } - forward_to_deserialize! { + forward_to_deserialize_any! { bool u8 u16 u32 u64 i8 i16 i32 i64 f32 f64 char str string unit option seq seq_fixed_size bytes byte_buf map unit_struct newtype_struct tuple_struct struct identifier tuple enum ignored_any @@ -1615,14 +1615,14 @@ mod content { type Error = E; #[inline] - fn deserialize(self, visitor: V) -> Result + fn deserialize_any(self, visitor: V) -> Result where V: de::Visitor<'de>, { visitor.visit_map(self) } - forward_to_deserialize! { + forward_to_deserialize_any! { bool u8 u16 u32 u64 i8 i16 i32 i64 f32 f64 char str string unit option seq seq_fixed_size bytes byte_buf map unit_struct newtype_struct tuple_struct struct identifier tuple enum ignored_any diff --git a/serde_derive/src/de.rs b/serde_derive/src/de.rs index 994b9a9b..6eb3846b 100644 --- a/serde_derive/src/de.rs +++ b/serde_derive/src/de.rs @@ -497,7 +497,7 @@ fn deserialize_struct( }; let dispatch = if let Some(deserializer) = deserializer { quote! { - _serde::Deserializer::deserialize(#deserializer, #visitor_expr) + _serde::Deserializer::deserialize_any(#deserializer, #visitor_expr) } } else if is_enum { quote! { @@ -729,7 +729,7 @@ fn deserialize_internally_tagged_enum( #variants_stmt - let __tagged = try!(_serde::Deserializer::deserialize( + let __tagged = try!(_serde::Deserializer::deserialize_any( __deserializer, _serde::private::de::TaggedContentVisitor::<__Field>::new(#tag))); @@ -1083,7 +1083,7 @@ fn deserialize_internally_tagged_variant( let type_name = params.type_name(); let variant_name = variant.ident.as_ref(); quote_block! { - try!(_serde::Deserializer::deserialize(#deserializer, _serde::private::de::InternallyTaggedUnitVisitor::new(#type_name, #variant_name))); + try!(_serde::Deserializer::deserialize_any(#deserializer, _serde::private::de::InternallyTaggedUnitVisitor::new(#type_name, #variant_name))); _serde::export::Ok(#this::#variant_ident) } } @@ -1109,7 +1109,7 @@ fn deserialize_untagged_variant( let variant_name = variant.ident.as_ref(); quote_expr! { _serde::export::Result::map( - _serde::Deserializer::deserialize( + _serde::Deserializer::deserialize_any( #deserializer, _serde::private::de::UntaggedUnitVisitor::new(#type_name, #variant_name) ), diff --git a/serde_test/src/de.rs b/serde_test/src/de.rs index b6ce5725..cef4bcae 100644 --- a/serde_test/src/de.rs +++ b/serde_test/src/de.rs @@ -97,12 +97,12 @@ impl<'de> Deserializer<'de> { impl<'de, 'a> de::Deserializer<'de> for &'a mut Deserializer<'de> { type Error = Error; - forward_to_deserialize! { + forward_to_deserialize_any! { bool u8 u16 u32 u64 i8 i16 i32 i64 f32 f64 char str string unit seq bytes byte_buf map identifier ignored_any } - fn deserialize(self, visitor: V) -> Result + fn deserialize_any(self, visitor: V) -> Result where V: Visitor<'de>, { @@ -192,7 +192,7 @@ impl<'de, 'a> de::Deserializer<'de> for &'a mut Deserializer<'de> { self.next_token(); visitor.visit_some(self) } - Some(_) => self.deserialize(visitor), + Some(_) => self.deserialize_any(visitor), None => Err(Error::EndOfTokens), } } @@ -239,7 +239,7 @@ impl<'de, 'a> de::Deserializer<'de> for &'a mut Deserializer<'de> { Err(Error::InvalidName(n)) } } - Some(_) => self.deserialize(visitor), + Some(_) => self.deserialize_any(visitor), None => Err(Error::EndOfTokens), } } @@ -257,7 +257,7 @@ impl<'de, 'a> de::Deserializer<'de> for &'a mut Deserializer<'de> { Err(Error::InvalidName(n)) } } - Some(_) => self.deserialize(visitor), + Some(_) => self.deserialize_any(visitor), None => Err(Error::EndOfTokens), } } @@ -271,7 +271,7 @@ impl<'de, 'a> de::Deserializer<'de> for &'a mut Deserializer<'de> { self.next_token(); self.visit_seq(Some(len), Token::SeqEnd, visitor) } - Some(_) => self.deserialize(visitor), + Some(_) => self.deserialize_any(visitor), None => Err(Error::EndOfTokens), } } @@ -302,7 +302,7 @@ impl<'de, 'a> de::Deserializer<'de> for &'a mut Deserializer<'de> { self.next_token(); self.visit_seq(Some(len), Token::TupleStructEnd, visitor) } - Some(_) => self.deserialize(visitor), + Some(_) => self.deserialize_any(visitor), None => Err(Error::EndOfTokens), } } @@ -349,7 +349,7 @@ impl<'de, 'a> de::Deserializer<'de> for &'a mut Deserializer<'de> { Err(Error::InvalidName(n)) } } - Some(_) => self.deserialize(visitor), + Some(_) => self.deserialize_any(visitor), None => Err(Error::EndOfTokens), } } @@ -376,7 +376,7 @@ impl<'de, 'a> de::Deserializer<'de> for &'a mut Deserializer<'de> { self.next_token(); self.visit_map(Some(fields.len()), Token::MapEnd, visitor) } - Some(_) => self.deserialize(visitor), + Some(_) => self.deserialize_any(visitor), None => Err(Error::EndOfTokens), } } @@ -529,7 +529,7 @@ impl<'de, 'a> VariantAccess<'de> for DeserializerEnumVisitor<'a, 'de> { Err(Error::UnexpectedToken(token)) } } - Some(_) => de::Deserializer::deserialize(self.de, visitor), + Some(_) => de::Deserializer::deserialize_any(self.de, visitor), None => Err(Error::EndOfTokens), } } @@ -559,7 +559,7 @@ impl<'de, 'a> VariantAccess<'de> for DeserializerEnumVisitor<'a, 'de> { Err(Error::UnexpectedToken(token)) } } - Some(_) => de::Deserializer::deserialize(self.de, visitor), + Some(_) => de::Deserializer::deserialize_any(self.de, visitor), None => Err(Error::EndOfTokens), } } @@ -649,14 +649,14 @@ struct BytesDeserializer { impl<'de> de::Deserializer<'de> for BytesDeserializer { type Error = Error; - fn deserialize(self, visitor: V) -> Result + fn deserialize_any(self, visitor: V) -> Result where V: de::Visitor<'de>, { visitor.visit_bytes(self.value) } - forward_to_deserialize! { + forward_to_deserialize_any! { bool u8 u16 u32 u64 i8 i16 i32 i64 f32 f64 char str string unit option seq seq_fixed_size bytes map unit_struct newtype_struct tuple_struct struct identifier tuple enum ignored_any byte_buf