diff --git a/serde/src/de/mod.rs b/serde/src/de/mod.rs index a8275ef6..ef8582c8 100644 --- a/serde/src/de/mod.rs +++ b/serde/src/de/mod.rs @@ -985,12 +985,6 @@ pub trait Deserializer<'de>: Sized { where V: Visitor<'de>; - /// Hint that the `Deserialize` type is expecting the name of a struct - /// field or the discriminant of an enum variant. - fn deserialize_identifier(self, visitor: V) -> Result - where - V: Visitor<'de>; - /// Hint that the `Deserialize` type is expecting an enum value with a /// particular name and possible variants. fn deserialize_enum( @@ -1002,6 +996,12 @@ pub trait Deserializer<'de>: Sized { where V: Visitor<'de>; + /// Hint that the `Deserialize` type is expecting the name of a struct + /// field or the discriminant of an enum variant. + fn deserialize_identifier(self, visitor: V) -> Result + where + V: Visitor<'de>; + /// Hint that the `Deserialize` type needs to deserialize a value whose type /// doesn't matter because it is ignored. /// diff --git a/serde/src/de/value.rs b/serde/src/de/value.rs index ec311be8..ffedb3ef 100644 --- a/serde/src/de/value.rs +++ b/serde/src/de/value.rs @@ -131,7 +131,7 @@ where forward_to_deserialize_any! { bool i8 i16 i32 i64 u8 u16 u32 u64 f32 f64 char str string bytes byte_buf unit unit_struct newtype_struct seq seq_fixed_size tuple - tuple_struct map struct identifier enum ignored_any + tuple_struct map struct enum identifier ignored_any } fn deserialize_any(self, visitor: V) -> Result @@ -184,7 +184,7 @@ macro_rules! primitive_deserializer { forward_to_deserialize_any! { bool i8 i16 i32 i64 u8 u16 u32 u64 f32 f64 char str string bytes byte_buf option unit unit_struct newtype_struct seq seq_fixed_size - tuple tuple_struct map struct identifier enum ignored_any + tuple tuple_struct map struct enum identifier ignored_any } fn deserialize_any(self, visitor: V) -> Result @@ -574,7 +574,7 @@ where forward_to_deserialize_any! { bool i8 i16 i32 i64 u8 u16 u32 u64 f32 f64 char str string bytes byte_buf option unit unit_struct newtype_struct seq seq_fixed_size - tuple tuple_struct map struct identifier enum ignored_any + tuple tuple_struct map struct enum identifier ignored_any } } @@ -688,7 +688,7 @@ where forward_to_deserialize_any! { bool i8 i16 i32 i64 u8 u16 u32 u64 f32 f64 char str string bytes byte_buf option unit unit_struct newtype_struct seq seq_fixed_size - tuple tuple_struct map struct identifier enum ignored_any + tuple tuple_struct map struct enum identifier ignored_any } } @@ -806,7 +806,7 @@ where forward_to_deserialize_any! { bool i8 i16 i32 i64 u8 u16 u32 u64 f32 f64 char str string bytes byte_buf option unit unit_struct newtype_struct tuple tuple_struct - map struct identifier enum ignored_any + map struct enum identifier ignored_any } } @@ -947,7 +947,7 @@ where forward_to_deserialize_any! { bool i8 i16 i32 i64 u8 u16 u32 u64 f32 f64 char str string bytes byte_buf option unit unit_struct newtype_struct tuple tuple_struct - map struct identifier enum ignored_any + map struct enum identifier ignored_any } fn deserialize_any(self, visitor: V) -> Result @@ -1094,7 +1094,7 @@ where forward_to_deserialize_any! { bool i8 i16 i32 i64 u8 u16 u32 u64 f32 f64 char str string bytes byte_buf option unit unit_struct newtype_struct seq seq_fixed_size - tuple tuple_struct map struct identifier enum ignored_any + tuple tuple_struct map struct enum identifier ignored_any } } diff --git a/serde/src/macros.rs b/serde/src/macros.rs index b3d5d402..0d654583 100644 --- a/serde/src/macros.rs +++ b/serde/src/macros.rs @@ -79,7 +79,7 @@ /// forward_to_deserialize_any! { /// bool i8 i16 i32 i64 u8 u16 u32 u64 f32 f64 char str string bytes /// byte_buf option unit unit_struct newtype_struct seq seq_fixed_size -/// tuple tuple_struct map struct identifier enum ignored_any +/// tuple tuple_struct map struct enum identifier ignored_any /// } /// } /// # @@ -114,7 +114,7 @@ /// > /// bool i8 i16 i32 i64 u8 u16 u32 u64 f32 f64 char str string bytes /// byte_buf option unit unit_struct newtype_struct seq seq_fixed_size -/// tuple tuple_struct map struct identifier enum ignored_any +/// tuple tuple_struct map struct enum identifier ignored_any /// } /// # } /// # @@ -233,12 +233,12 @@ macro_rules! forward_to_deserialize_any_helper { (struct<$l:tt, $v:ident>) => { forward_to_deserialize_any_method!{deserialize_struct<$l, $v>(name: &'static str, fields: &'static [&'static str])} }; - (identifier<$l:tt, $v:ident>) => { - forward_to_deserialize_any_method!{deserialize_identifier<$l, $v>()} - }; (enum<$l:tt, $v:ident>) => { forward_to_deserialize_any_method!{deserialize_enum<$l, $v>(name: &'static str, variants: &'static [&'static str])} }; + (identifier<$l:tt, $v:ident>) => { + forward_to_deserialize_any_method!{deserialize_identifier<$l, $v>()} + }; (ignored_any<$l:tt, $v:ident>) => { 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 61bbf566..52d2c143 100644 --- a/serde/src/private/de.rs +++ b/serde/src/private/de.rs @@ -50,7 +50,7 @@ where forward_to_deserialize_any! { bool i8 i16 i32 i64 u8 u16 u32 u64 f32 f64 char str string bytes byte_buf unit unit_struct newtype_struct seq seq_fixed_size tuple - tuple_struct map struct identifier enum ignored_any + tuple_struct map struct enum identifier ignored_any } } @@ -1154,7 +1154,7 @@ mod content { forward_to_deserialize_any! { bool i8 i16 i32 i64 u8 u16 u32 u64 f32 f64 char str string bytes byte_buf option unit unit_struct newtype_struct seq seq_fixed_size - tuple tuple_struct map struct identifier enum ignored_any + tuple tuple_struct map struct enum identifier ignored_any } } @@ -1255,7 +1255,7 @@ mod content { forward_to_deserialize_any! { bool i8 i16 i32 i64 u8 u16 u32 u64 f32 f64 char str string bytes byte_buf option unit unit_struct newtype_struct seq seq_fixed_size - tuple tuple_struct map struct identifier enum ignored_any + tuple tuple_struct map struct enum identifier ignored_any } } @@ -1546,7 +1546,7 @@ mod content { forward_to_deserialize_any! { bool i8 i16 i32 i64 u8 u16 u32 u64 f32 f64 char str string bytes byte_buf option unit unit_struct newtype_struct seq seq_fixed_size - tuple tuple_struct map struct identifier enum ignored_any + tuple tuple_struct map struct enum identifier ignored_any } } @@ -1648,7 +1648,7 @@ mod content { forward_to_deserialize_any! { bool i8 i16 i32 i64 u8 u16 u32 u64 f32 f64 char str string bytes byte_buf option unit unit_struct newtype_struct seq seq_fixed_size - tuple tuple_struct map struct identifier enum ignored_any + tuple tuple_struct map struct enum identifier ignored_any } } @@ -1805,7 +1805,7 @@ where forward_to_deserialize_any! { bool i8 i16 i32 i64 u8 u16 u32 u64 f32 f64 char str string bytes byte_buf option unit unit_struct newtype_struct seq seq_fixed_size - tuple tuple_struct map struct identifier enum ignored_any + tuple tuple_struct map struct enum identifier ignored_any } } @@ -1844,6 +1844,6 @@ where forward_to_deserialize_any! { bool i8 i16 i32 i64 u8 u16 u32 u64 f32 f64 char str string bytes byte_buf option unit unit_struct newtype_struct seq seq_fixed_size - tuple tuple_struct map struct identifier enum ignored_any + tuple tuple_struct map struct enum identifier ignored_any } } diff --git a/serde_test/src/de.rs b/serde_test/src/de.rs index a1f497c7..7139dbac 100644 --- a/serde_test/src/de.rs +++ b/serde_test/src/de.rs @@ -657,6 +657,6 @@ impl<'de> de::Deserializer<'de> for BytesDeserializer { forward_to_deserialize_any! { bool i8 i16 i32 i64 u8 u16 u32 u64 f32 f64 char str string bytes byte_buf option unit unit_struct newtype_struct seq seq_fixed_size - tuple tuple_struct map struct identifier enum ignored_any + tuple tuple_struct map struct enum identifier ignored_any } }