Merge pull request #231 from erickt/rename-struct-key-to-field
Rename struct key to field
This commit is contained in:
commit
8c8fcdbc54
@ -332,8 +332,8 @@ pub trait Deserializer {
|
||||
/// deserializers to a unit struct that aren't tagged as a unit struct.
|
||||
#[inline]
|
||||
fn deserialize_unit_struct<V>(&mut self,
|
||||
_name: &'static str,
|
||||
visitor: V) -> Result<V::Value, Self::Error>
|
||||
_name: &'static str,
|
||||
visitor: V) -> Result<V::Value, Self::Error>
|
||||
where V: 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.
|
||||
#[inline]
|
||||
fn deserialize_newtype_struct<V>(&mut self,
|
||||
name: &'static str,
|
||||
visitor: V) -> Result<V::Value, Self::Error>
|
||||
name: &'static str,
|
||||
visitor: V) -> Result<V::Value, Self::Error>
|
||||
where V: 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.
|
||||
#[inline]
|
||||
fn deserialize_tuple_struct<V>(&mut self,
|
||||
_name: &'static str,
|
||||
len: usize,
|
||||
visitor: V) -> Result<V::Value, Self::Error>
|
||||
_name: &'static str,
|
||||
len: usize,
|
||||
visitor: V) -> Result<V::Value, Self::Error>
|
||||
where V: Visitor,
|
||||
{
|
||||
self.deserialize_tuple(len, visitor)
|
||||
@ -366,9 +366,9 @@ pub trait Deserializer {
|
||||
/// deserializers to parse sequences that aren't tagged as maps.
|
||||
#[inline]
|
||||
fn deserialize_struct<V>(&mut self,
|
||||
_name: &'static str,
|
||||
_fields: &'static [&'static str],
|
||||
visitor: V) -> Result<V::Value, Self::Error>
|
||||
_name: &'static str,
|
||||
_fields: &'static [&'static str],
|
||||
visitor: V) -> Result<V::Value, Self::Error>
|
||||
where V: Visitor,
|
||||
{
|
||||
self.deserialize_map(visitor)
|
||||
@ -388,9 +388,9 @@ pub trait Deserializer {
|
||||
/// type.
|
||||
#[inline]
|
||||
fn deserialize_enum<V>(&mut self,
|
||||
_enum: &'static str,
|
||||
_variants: &'static [&'static str],
|
||||
_visitor: V) -> Result<V::Value, Self::Error>
|
||||
_enum: &'static str,
|
||||
_variants: &'static [&'static str],
|
||||
_visitor: V) -> Result<V::Value, Self::Error>
|
||||
where V: EnumVisitor,
|
||||
{
|
||||
Err(Error::syntax("expected an enum"))
|
||||
@ -406,11 +406,11 @@ pub trait Deserializer {
|
||||
self.deserialize_seq(visitor)
|
||||
}
|
||||
|
||||
/// This method hints that the `Deserialize` type is expecting some sort of struct key mapping.
|
||||
/// This allows deserializers to choose between &str, usize, or &[u8] to properly deserialize a
|
||||
/// struct key.
|
||||
/// This method hints that the `Deserialize` type is expecting some sort of struct field
|
||||
/// mapping. This allows deserializers to choose between &str, usize, or &[u8] to properly
|
||||
/// deserialize a struct field.
|
||||
#[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,
|
||||
{
|
||||
self.deserialize(visitor)
|
||||
@ -843,8 +843,8 @@ impl<'a, T> VariantVisitor for &'a mut T where T: VariantVisitor {
|
||||
}
|
||||
|
||||
fn visit_struct<V>(&mut self,
|
||||
fields: &'static [&'static str],
|
||||
visitor: V) -> Result<V::Value, T::Error>
|
||||
fields: &'static [&'static str],
|
||||
visitor: V) -> Result<V::Value, T::Error>
|
||||
where V: Visitor,
|
||||
{
|
||||
(**self).visit_struct(fields, visitor)
|
||||
|
@ -146,9 +146,9 @@ pub trait Serializer {
|
||||
/// By default, unit variants are serialized as a `()`.
|
||||
#[inline]
|
||||
fn serialize_unit_variant(&mut self,
|
||||
_name: &'static str,
|
||||
_variant_index: usize,
|
||||
_variant: &'static str) -> Result<(), Self::Error> {
|
||||
_name: &'static str,
|
||||
_variant_index: usize,
|
||||
_variant: &'static str) -> Result<(), Self::Error> {
|
||||
self.serialize_unit()
|
||||
}
|
||||
|
||||
@ -157,8 +157,8 @@ pub trait Serializer {
|
||||
/// By default it just serializes the value as a tuple struct sequence.
|
||||
#[inline]
|
||||
fn serialize_newtype_struct<T>(&mut self,
|
||||
name: &'static str,
|
||||
value: T) -> Result<(), Self::Error>
|
||||
name: &'static str,
|
||||
value: T) -> Result<(), Self::Error>
|
||||
where T: Serialize,
|
||||
{
|
||||
self.serialize_tuple_struct(name, Some(value))
|
||||
@ -169,10 +169,10 @@ pub trait Serializer {
|
||||
/// tuple variant sequence.
|
||||
#[inline]
|
||||
fn serialize_newtype_variant<T>(&mut self,
|
||||
name: &'static str,
|
||||
variant_index: usize,
|
||||
variant: &'static str,
|
||||
value: T) -> Result<(), Self::Error>
|
||||
name: &'static str,
|
||||
variant_index: usize,
|
||||
variant: &'static str,
|
||||
value: T) -> Result<(), Self::Error>
|
||||
where T: Serialize,
|
||||
{
|
||||
self.serialize_tuple_variant(
|
||||
@ -225,8 +225,8 @@ pub trait Serializer {
|
||||
/// By default, tuple structs are serialized as a tuple.
|
||||
#[inline]
|
||||
fn serialize_tuple_struct<V>(&mut self,
|
||||
_name: &'static str,
|
||||
visitor: V) -> Result<(), Self::Error>
|
||||
_name: &'static str,
|
||||
visitor: V) -> Result<(), Self::Error>
|
||||
where V: SeqVisitor,
|
||||
{
|
||||
self.serialize_tuple(visitor)
|
||||
@ -247,10 +247,10 @@ pub trait Serializer {
|
||||
/// By default, tuple variants are serialized as a tuple struct.
|
||||
#[inline]
|
||||
fn serialize_tuple_variant<V>(&mut self,
|
||||
_name: &'static str,
|
||||
_variant_index: usize,
|
||||
variant: &'static str,
|
||||
visitor: V) -> Result<(), Self::Error>
|
||||
_name: &'static str,
|
||||
_variant_index: usize,
|
||||
variant: &'static str,
|
||||
visitor: V) -> Result<(), Self::Error>
|
||||
where V: SeqVisitor,
|
||||
{
|
||||
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.
|
||||
#[inline]
|
||||
fn serialize_struct<V>(&mut self,
|
||||
_name: &'static str,
|
||||
visitor: V) -> Result<(), Self::Error>
|
||||
_name: &'static str,
|
||||
visitor: V) -> Result<(), Self::Error>
|
||||
where V: MapVisitor,
|
||||
{
|
||||
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.
|
||||
#[inline]
|
||||
fn serialize_struct_elt<V>(&mut self,
|
||||
key: &'static str,
|
||||
value: V) -> Result<(), Self::Error>
|
||||
key: &'static str,
|
||||
value: V) -> Result<(), Self::Error>
|
||||
where V: Serialize,
|
||||
{
|
||||
self.serialize_map_elt(key, value)
|
||||
@ -307,10 +307,10 @@ pub trait Serializer {
|
||||
/// By default, struct variants are serialized as a struct.
|
||||
#[inline]
|
||||
fn serialize_struct_variant<V>(&mut self,
|
||||
_name: &'static str,
|
||||
_variant_index: usize,
|
||||
variant: &'static str,
|
||||
visitor: V) -> Result<(), Self::Error>
|
||||
_name: &'static str,
|
||||
_variant_index: usize,
|
||||
variant: &'static str,
|
||||
visitor: V) -> Result<(), Self::Error>
|
||||
where V: MapVisitor,
|
||||
{
|
||||
self.serialize_struct(variant, visitor)
|
||||
@ -321,8 +321,8 @@ pub trait Serializer {
|
||||
/// By default, struct variant elements are serialized as a struct element.
|
||||
#[inline]
|
||||
fn serialize_struct_variant_elt<V>(&mut self,
|
||||
key: &'static str,
|
||||
value: V) -> Result<(), Self::Error>
|
||||
key: &'static str,
|
||||
value: V) -> Result<(), Self::Error>
|
||||
where V: Serialize,
|
||||
{
|
||||
self.serialize_struct_elt(key, value)
|
||||
|
@ -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();
|
||||
|
Loading…
Reference in New Issue
Block a user