Implement Serialize::visit_newtype_{struct,variant}
These functions allow a serializer to not wrap a newtyped value inside of a tuple or struct.
This commit is contained in:
parent
bbc167cde9
commit
b7b31bf9da
|
@ -59,6 +59,24 @@ impl ser::Serializer for Encoder {
|
|||
try!(value.serialize(self));
|
||||
Ok(())
|
||||
}
|
||||
fn visit_newtype_struct<T>(&mut self,
|
||||
_name: &'static str,
|
||||
value: T) -> Result<(), Self::Error>
|
||||
where T: ser::Serialize,
|
||||
{
|
||||
// Don't serialize the newtype struct in a tuple.
|
||||
value.serialize(self)
|
||||
}
|
||||
fn visit_newtype_variant<T>(&mut self,
|
||||
_name: &'static str,
|
||||
_variant_index: usize,
|
||||
_variant: &'static str,
|
||||
value: T) -> Result<(), Self::Error>
|
||||
where T: ser::Serialize,
|
||||
{
|
||||
// Don't serialize the newtype struct variant in a tuple.
|
||||
value.serialize(self)
|
||||
}
|
||||
}
|
||||
|
||||
impl ser::Serialize for Value {
|
||||
|
|
Loading…
Reference in a new issue