mirror of
https://gitee.com/openharmony/third_party_rust_serde
synced 2024-11-27 09:01:43 +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:
parent
850a29beb1
commit
35ad468780
@ -54,6 +54,13 @@ impl<'a, 'b> Serializer for &'a mut fmt::Formatter<'b> {
|
||||
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 {
|
||||
Err(fmt::Error)
|
||||
}
|
||||
@ -73,13 +80,6 @@ impl<'a, 'b> Serializer for &'a mut fmt::Formatter<'b> {
|
||||
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>(
|
||||
self,
|
||||
_name: &'static str,
|
||||
|
Loading…
Reference in New Issue
Block a user