Merge pull request #231 from erickt/rename-struct-key-to-field

Rename struct key to field
This commit is contained in:
Erick Tryzelaar 2016-02-07 20:35:38 -08:00
commit 8c8fcdbc54
3 changed files with 45 additions and 45 deletions

View File

@ -332,8 +332,8 @@ pub trait Deserializer {
/// deserializers to a unit struct that aren't tagged as a unit struct. /// deserializers to a unit struct that aren't tagged as a unit struct.
#[inline] #[inline]
fn deserialize_unit_struct<V>(&mut self, fn deserialize_unit_struct<V>(&mut self,
_name: &'static str, _name: &'static str,
visitor: V) -> Result<V::Value, Self::Error> visitor: V) -> Result<V::Value, Self::Error>
where V: Visitor, where V: Visitor,
{ {
self.deserialize_unit(visitor) self.deserialize_unit(visitor)
@ -343,8 +343,8 @@ pub trait Deserializer {
/// deserializers to a newtype struct that aren't tagged as a newtype struct. /// deserializers to a newtype struct that aren't tagged as a newtype struct.
#[inline] #[inline]
fn deserialize_newtype_struct<V>(&mut self, fn deserialize_newtype_struct<V>(&mut self,
name: &'static str, name: &'static str,
visitor: V) -> Result<V::Value, Self::Error> visitor: V) -> Result<V::Value, Self::Error>
where V: Visitor, where V: Visitor,
{ {
self.deserialize_tuple_struct(name, 1, visitor) self.deserialize_tuple_struct(name, 1, visitor)
@ -354,9 +354,9 @@ pub trait Deserializer {
/// deserializers to parse sequences that aren't tagged as sequences. /// deserializers to parse sequences that aren't tagged as sequences.
#[inline] #[inline]
fn deserialize_tuple_struct<V>(&mut self, fn deserialize_tuple_struct<V>(&mut self,
_name: &'static str, _name: &'static str,
len: usize, len: usize,
visitor: V) -> Result<V::Value, Self::Error> visitor: V) -> Result<V::Value, Self::Error>
where V: Visitor, where V: Visitor,
{ {
self.deserialize_tuple(len, visitor) self.deserialize_tuple(len, visitor)
@ -366,9 +366,9 @@ pub trait Deserializer {
/// deserializers to parse sequences that aren't tagged as maps. /// deserializers to parse sequences that aren't tagged as maps.
#[inline] #[inline]
fn deserialize_struct<V>(&mut self, fn deserialize_struct<V>(&mut self,
_name: &'static str, _name: &'static str,
_fields: &'static [&'static str], _fields: &'static [&'static str],
visitor: V) -> Result<V::Value, Self::Error> visitor: V) -> Result<V::Value, Self::Error>
where V: Visitor, where V: Visitor,
{ {
self.deserialize_map(visitor) self.deserialize_map(visitor)
@ -388,9 +388,9 @@ pub trait Deserializer {
/// type. /// type.
#[inline] #[inline]
fn deserialize_enum<V>(&mut self, fn deserialize_enum<V>(&mut self,
_enum: &'static str, _enum: &'static str,
_variants: &'static [&'static str], _variants: &'static [&'static str],
_visitor: V) -> Result<V::Value, Self::Error> _visitor: V) -> Result<V::Value, Self::Error>
where V: EnumVisitor, where V: EnumVisitor,
{ {
Err(Error::syntax("expected an enum")) Err(Error::syntax("expected an enum"))
@ -406,11 +406,11 @@ pub trait Deserializer {
self.deserialize_seq(visitor) self.deserialize_seq(visitor)
} }
/// This method hints that the `Deserialize` type is expecting some sort of struct key mapping. /// This method hints that the `Deserialize` type is expecting some sort of struct field
/// This allows deserializers to choose between &str, usize, or &[u8] to properly deserialize a /// mapping. This allows deserializers to choose between &str, usize, or &[u8] to properly
/// struct key. /// deserialize a struct field.
#[inline] #[inline]
fn deserialize_struct_key<V>(&mut self, visitor: V) -> Result<V::Value, Self::Error> fn deserialize_struct_field<V>(&mut self, visitor: V) -> Result<V::Value, Self::Error>
where V: Visitor, where V: Visitor,
{ {
self.deserialize(visitor) self.deserialize(visitor)
@ -843,8 +843,8 @@ impl<'a, T> VariantVisitor for &'a mut T where T: VariantVisitor {
} }
fn visit_struct<V>(&mut self, fn visit_struct<V>(&mut self,
fields: &'static [&'static str], fields: &'static [&'static str],
visitor: V) -> Result<V::Value, T::Error> visitor: V) -> Result<V::Value, T::Error>
where V: Visitor, where V: Visitor,
{ {
(**self).visit_struct(fields, visitor) (**self).visit_struct(fields, visitor)

View File

@ -146,9 +146,9 @@ pub trait Serializer {
/// By default, unit variants are serialized as a `()`. /// By default, unit variants are serialized as a `()`.
#[inline] #[inline]
fn serialize_unit_variant(&mut self, fn serialize_unit_variant(&mut self,
_name: &'static str, _name: &'static str,
_variant_index: usize, _variant_index: usize,
_variant: &'static str) -> Result<(), Self::Error> { _variant: &'static str) -> Result<(), Self::Error> {
self.serialize_unit() self.serialize_unit()
} }
@ -157,8 +157,8 @@ pub trait Serializer {
/// By default it just serializes the value as a tuple struct sequence. /// By default it just serializes the value as a tuple struct sequence.
#[inline] #[inline]
fn serialize_newtype_struct<T>(&mut self, fn serialize_newtype_struct<T>(&mut self,
name: &'static str, name: &'static str,
value: T) -> Result<(), Self::Error> value: T) -> Result<(), Self::Error>
where T: Serialize, where T: Serialize,
{ {
self.serialize_tuple_struct(name, Some(value)) self.serialize_tuple_struct(name, Some(value))
@ -169,10 +169,10 @@ pub trait Serializer {
/// tuple variant sequence. /// tuple variant sequence.
#[inline] #[inline]
fn serialize_newtype_variant<T>(&mut self, fn serialize_newtype_variant<T>(&mut self,
name: &'static str, name: &'static str,
variant_index: usize, variant_index: usize,
variant: &'static str, variant: &'static str,
value: T) -> Result<(), Self::Error> value: T) -> Result<(), Self::Error>
where T: Serialize, where T: Serialize,
{ {
self.serialize_tuple_variant( self.serialize_tuple_variant(
@ -225,8 +225,8 @@ pub trait Serializer {
/// By default, tuple structs are serialized as a tuple. /// By default, tuple structs are serialized as a tuple.
#[inline] #[inline]
fn serialize_tuple_struct<V>(&mut self, fn serialize_tuple_struct<V>(&mut self,
_name: &'static str, _name: &'static str,
visitor: V) -> Result<(), Self::Error> visitor: V) -> Result<(), Self::Error>
where V: SeqVisitor, where V: SeqVisitor,
{ {
self.serialize_tuple(visitor) self.serialize_tuple(visitor)
@ -247,10 +247,10 @@ pub trait Serializer {
/// By default, tuple variants are serialized as a tuple struct. /// By default, tuple variants are serialized as a tuple struct.
#[inline] #[inline]
fn serialize_tuple_variant<V>(&mut self, fn serialize_tuple_variant<V>(&mut self,
_name: &'static str, _name: &'static str,
_variant_index: usize, _variant_index: usize,
variant: &'static str, variant: &'static str,
visitor: V) -> Result<(), Self::Error> visitor: V) -> Result<(), Self::Error>
where V: SeqVisitor, where V: SeqVisitor,
{ {
self.serialize_tuple_struct(variant, visitor) self.serialize_tuple_struct(variant, visitor)
@ -283,8 +283,8 @@ pub trait Serializer {
/// By default, structs are serialized as a map with the field name as the key. /// By default, structs are serialized as a map with the field name as the key.
#[inline] #[inline]
fn serialize_struct<V>(&mut self, fn serialize_struct<V>(&mut self,
_name: &'static str, _name: &'static str,
visitor: V) -> Result<(), Self::Error> visitor: V) -> Result<(), Self::Error>
where V: MapVisitor, where V: MapVisitor,
{ {
self.serialize_map(visitor) self.serialize_map(visitor)
@ -295,8 +295,8 @@ pub trait Serializer {
/// By default, struct elements are serialized as a map element with the field name as the key. /// By default, struct elements are serialized as a map element with the field name as the key.
#[inline] #[inline]
fn serialize_struct_elt<V>(&mut self, fn serialize_struct_elt<V>(&mut self,
key: &'static str, key: &'static str,
value: V) -> Result<(), Self::Error> value: V) -> Result<(), Self::Error>
where V: Serialize, where V: Serialize,
{ {
self.serialize_map_elt(key, value) self.serialize_map_elt(key, value)
@ -307,10 +307,10 @@ pub trait Serializer {
/// By default, struct variants are serialized as a struct. /// By default, struct variants are serialized as a struct.
#[inline] #[inline]
fn serialize_struct_variant<V>(&mut self, fn serialize_struct_variant<V>(&mut self,
_name: &'static str, _name: &'static str,
_variant_index: usize, _variant_index: usize,
variant: &'static str, variant: &'static str,
visitor: V) -> Result<(), Self::Error> visitor: V) -> Result<(), Self::Error>
where V: MapVisitor, where V: MapVisitor,
{ {
self.serialize_struct(variant, visitor) self.serialize_struct(variant, visitor)
@ -321,8 +321,8 @@ pub trait Serializer {
/// By default, struct variant elements are serialized as a struct element. /// By default, struct variant elements are serialized as a struct element.
#[inline] #[inline]
fn serialize_struct_variant_elt<V>(&mut self, fn serialize_struct_variant_elt<V>(&mut self,
key: &'static str, key: &'static str,
value: V) -> Result<(), Self::Error> value: V) -> Result<(), Self::Error>
where V: Serialize, where V: Serialize,
{ {
self.serialize_struct_elt(key, value) self.serialize_struct_elt(key, value)

View File

@ -949,7 +949,7 @@ fn deserialize_field_visitor(
} }
} }
deserializer.deserialize_struct_key(__FieldVisitor::<D>{ phantom: PhantomData }) deserializer.deserialize_struct_field(__FieldVisitor::<D>{ phantom: PhantomData })
} }
} }
).unwrap(); ).unwrap();