From a38b24136b44618af5e2fff77d822c6d0ad25efc Mon Sep 17 00:00:00 2001 From: David Tolnay Date: Sun, 9 Apr 2017 13:35:20 -0700 Subject: [PATCH] Rename deserialize_struct_field to deserialize_identifier Because it applies to both struct fields and discriminants of an enum. --- serde/src/de/impls.rs | 4 ++-- serde/src/de/mod.rs | 4 ++-- serde/src/de/value.rs | 22 +++++++++++----------- serde/src/macros.rs | 8 ++++---- serde/src/private/de.rs | 14 +++++++------- serde_derive/src/de.rs | 2 +- serde_test/src/de.rs | 4 ++-- 7 files changed, 29 insertions(+), 29 deletions(-) diff --git a/serde/src/de/impls.rs b/serde/src/de/impls.rs index 59793812..ffe3291c 100644 --- a/serde/src/de/impls.rs +++ b/serde/src/de/impls.rs @@ -1232,7 +1232,7 @@ impl<'de> Deserialize<'de> for Duration { } } - deserializer.deserialize_struct_field(FieldVisitor) + deserializer.deserialize_identifier(FieldVisitor) } } @@ -1358,7 +1358,7 @@ impl<'de, Idx: Deserialize<'de>> Deserialize<'de> for std::ops::Range { } } - deserializer.deserialize_struct_field(FieldVisitor) + deserializer.deserialize_identifier(FieldVisitor) } } diff --git a/serde/src/de/mod.rs b/serde/src/de/mod.rs index 453a531b..754fa12e 100644 --- a/serde/src/de/mod.rs +++ b/serde/src/de/mod.rs @@ -911,8 +911,8 @@ pub trait Deserializer<'de>: Sized { where V: Visitor<'de>; /// Hint that the `Deserialize` type is expecting the name of a struct - /// field. - fn deserialize_struct_field(self, visitor: V) -> Result + /// 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 diff --git a/serde/src/de/value.rs b/serde/src/de/value.rs index 3b157b0c..1323450d 100644 --- a/serde/src/de/value.rs +++ b/serde/src/de/value.rs @@ -108,7 +108,7 @@ impl<'de, E> de::Deserializer<'de> for UnitDeserializer forward_to_deserialize! { 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 - struct_field tuple enum ignored_any byte_buf + identifier tuple enum ignored_any byte_buf } fn deserialize(self, visitor: V) -> Result @@ -155,7 +155,7 @@ macro_rules! primitive_deserializer { forward_to_deserialize! { 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 struct_field tuple enum ignored_any byte_buf + tuple_struct struct identifier tuple enum ignored_any byte_buf } fn deserialize(self, visitor: V) -> Result @@ -208,7 +208,7 @@ impl<'de, E> de::Deserializer<'de> for U32Deserializer forward_to_deserialize! { 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 struct_field tuple ignored_any byte_buf + struct identifier tuple ignored_any byte_buf } fn deserialize(self, visitor: V) -> Result @@ -286,7 +286,7 @@ impl<'de, 'a, E> de::Deserializer<'de> for StrDeserializer<'a, E> forward_to_deserialize! { 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 struct_field tuple ignored_any byte_buf + struct identifier tuple ignored_any byte_buf } } @@ -351,7 +351,7 @@ impl<'de, E> de::Deserializer<'de> for StringDeserializer forward_to_deserialize! { 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 struct_field tuple ignored_any byte_buf + struct identifier tuple ignored_any byte_buf } } @@ -420,7 +420,7 @@ impl<'de, 'a, E> de::Deserializer<'de> for CowStrDeserializer<'a, E> forward_to_deserialize! { 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 struct_field tuple ignored_any byte_buf + struct identifier tuple ignored_any byte_buf } } @@ -495,7 +495,7 @@ impl<'de, I, T, E> de::Deserializer<'de> for SeqDeserializer forward_to_deserialize! { 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 struct_field tuple enum ignored_any byte_buf + struct identifier tuple enum ignored_any byte_buf } } @@ -603,7 +603,7 @@ impl<'de, V_> de::Deserializer<'de> for SeqVisitorDeserializer forward_to_deserialize! { 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 struct_field tuple enum ignored_any byte_buf + struct identifier tuple enum ignored_any byte_buf } } @@ -707,7 +707,7 @@ impl<'de, I, E> de::Deserializer<'de> for MapDeserializer<'de, I, E> forward_to_deserialize! { 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 struct_field + bytes map unit_struct newtype_struct tuple_struct struct identifier tuple enum ignored_any byte_buf } } @@ -804,7 +804,7 @@ impl<'de, A, B, E> de::Deserializer<'de> for PairDeserializer forward_to_deserialize! { 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 struct_field + bytes map unit_struct newtype_struct tuple_struct struct identifier tuple enum ignored_any byte_buf } @@ -945,7 +945,7 @@ impl<'de, V_> de::Deserializer<'de> for MapVisitorDeserializer forward_to_deserialize! { 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 struct_field tuple enum ignored_any byte_buf + struct identifier tuple enum ignored_any byte_buf } } diff --git a/serde/src/macros.rs b/serde/src/macros.rs index 5873e1a7..80ababfa 100644 --- a/serde/src/macros.rs +++ b/serde/src/macros.rs @@ -89,8 +89,8 @@ macro_rules! forward_to_deserialize_helper { (struct) => { forward_to_deserialize_method!{deserialize_struct(&'static str, &'static [&'static str])} }; - (struct_field) => { - forward_to_deserialize_method!{deserialize_struct_field()} + (identifier) => { + forward_to_deserialize_method!{deserialize_identifier()} }; (tuple) => { forward_to_deserialize_method!{deserialize_tuple(usize)} @@ -143,7 +143,7 @@ macro_rules! forward_to_deserialize_helper { /// # forward_to_deserialize! { /// # 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 struct_field tuple enum ignored_any +/// # tuple_struct struct identifier tuple enum ignored_any /// # } /// # } /// # @@ -176,7 +176,7 @@ macro_rules! forward_to_deserialize_helper { /// forward_to_deserialize! { /// 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 struct_field tuple enum ignored_any +/// tuple_struct struct identifier tuple enum ignored_any /// } /// } /// # diff --git a/serde/src/private/de.rs b/serde/src/private/de.rs index f4e95dc6..2d019b42 100644 --- a/serde/src/private/de.rs +++ b/serde/src/private/de.rs @@ -52,7 +52,7 @@ pub fn missing_field<'de, V, E>(field: &'static str) -> Result forward_to_deserialize! { 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 struct_field tuple enum ignored_any + tuple_struct struct identifier tuple enum ignored_any } } @@ -855,7 +855,7 @@ mod content { forward_to_deserialize! { 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 - struct_field tuple ignored_any + identifier tuple ignored_any } } @@ -996,7 +996,7 @@ mod content { forward_to_deserialize! { 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 struct_field tuple enum ignored_any + tuple_struct struct identifier tuple enum ignored_any } } @@ -1085,7 +1085,7 @@ mod content { forward_to_deserialize! { 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 struct_field tuple enum ignored_any + tuple_struct struct identifier tuple enum ignored_any } } @@ -1202,7 +1202,7 @@ mod content { forward_to_deserialize! { 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 - struct_field tuple ignored_any + identifier tuple ignored_any } } @@ -1341,7 +1341,7 @@ mod content { forward_to_deserialize! { 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 struct_field tuple enum ignored_any + tuple_struct struct identifier tuple enum ignored_any } } @@ -1430,7 +1430,7 @@ mod content { forward_to_deserialize! { 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 struct_field tuple enum ignored_any + tuple_struct struct identifier tuple enum ignored_any } } diff --git a/serde_derive/src/de.rs b/serde_derive/src/de.rs index 4c4ffe14..2335cce1 100644 --- a/serde_derive/src/de.rs +++ b/serde_derive/src/de.rs @@ -1190,7 +1190,7 @@ fn deserialize_field_visitor(fields: Vec<(String, Ident)>, } } - _serde::Deserializer::deserialize_struct_field(__deserializer, __FieldVisitor) + _serde::Deserializer::deserialize_identifier(__deserializer, __FieldVisitor) } } } diff --git a/serde_test/src/de.rs b/serde_test/src/de.rs index fcbb762b..243c8eb6 100644 --- a/serde_test/src/de.rs +++ b/serde_test/src/de.rs @@ -78,7 +78,7 @@ impl<'de, 'a> de::Deserializer<'de> for &'a mut Deserializer<'de> { forward_to_deserialize! { bool u8 u16 u32 u64 i8 i16 i32 i64 f32 f64 char str string unit - seq bytes byte_buf map struct_field ignored_any + seq bytes byte_buf map identifier ignored_any } fn deserialize(self, visitor: V) -> Result @@ -645,6 +645,6 @@ impl<'de> de::Deserializer<'de> for BytesDeserializer { forward_to_deserialize! { 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 struct_field tuple enum ignored_any byte_buf + struct identifier tuple enum ignored_any byte_buf } }