mirror of
https://github.com/pezkuwichain/serde.git
synced 2026-06-17 15:01:03 +00:00
Allow serializing newtype struct to Formatter
Serialize_newtype_struct is typically expected to just pass through the wrapped value.
This commit is contained in:
@@ -54,6 +54,13 @@ impl<'a, 'b> Serializer for &'a mut fmt::Formatter<'b> {
|
|||||||
Display::fmt(variant, self)
|
Display::fmt(variant, self)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn serialize_newtype_struct<T: ?Sized>(self, _name: &'static str, value: &T) -> fmt::Result
|
||||||
|
where
|
||||||
|
T: Serialize,
|
||||||
|
{
|
||||||
|
Serialize::serialize(value, self)
|
||||||
|
}
|
||||||
|
|
||||||
fn serialize_bytes(self, _v: &[u8]) -> fmt::Result {
|
fn serialize_bytes(self, _v: &[u8]) -> fmt::Result {
|
||||||
Err(fmt::Error)
|
Err(fmt::Error)
|
||||||
}
|
}
|
||||||
@@ -73,13 +80,6 @@ impl<'a, 'b> Serializer for &'a mut fmt::Formatter<'b> {
|
|||||||
Err(fmt::Error)
|
Err(fmt::Error)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn serialize_newtype_struct<T: ?Sized>(self, _name: &'static str, _value: &T) -> fmt::Result
|
|
||||||
where
|
|
||||||
T: Serialize,
|
|
||||||
{
|
|
||||||
Err(fmt::Error)
|
|
||||||
}
|
|
||||||
|
|
||||||
fn serialize_newtype_variant<T: ?Sized>(
|
fn serialize_newtype_variant<T: ?Sized>(
|
||||||
self,
|
self,
|
||||||
_name: &'static str,
|
_name: &'static str,
|
||||||
|
|||||||
Reference in New Issue
Block a user