Document that is_human_readable == false is a breaking change
This commit is contained in:
parent
a52f436788
commit
c2474bf6ee
@ -1016,6 +1016,9 @@ pub trait Deserializer<'de>: Sized {
|
|||||||
///
|
///
|
||||||
/// Some formats are not intended to be human readable. For these formats
|
/// Some formats are not intended to be human readable. For these formats
|
||||||
/// a type being serialized may opt to serialize into a more compact form.
|
/// a type being serialized may opt to serialize into a more compact form.
|
||||||
|
///
|
||||||
|
/// NOTE: Implementing this method and returning `false` is considered a breaking
|
||||||
|
/// change as it may alter how any given type tries to deserialize itself.
|
||||||
fn is_human_readable(&self) -> bool { true }
|
fn is_human_readable(&self) -> bool { true }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -506,9 +506,16 @@ impl Serialize for net::IpAddr {
|
|||||||
where
|
where
|
||||||
S: Serializer,
|
S: Serializer,
|
||||||
{
|
{
|
||||||
match *self {
|
if serializer.is_human_readable() {
|
||||||
net::IpAddr::V4(ref a) => a.serialize(serializer),
|
match *self {
|
||||||
net::IpAddr::V6(ref a) => a.serialize(serializer),
|
net::IpAddr::V4(ref a) => a.serialize(serializer),
|
||||||
|
net::IpAddr::V6(ref a) => a.serialize(serializer),
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
match *self {
|
||||||
|
net::IpAddr::V4(ref a) => (0u8, a).serialize(serializer),
|
||||||
|
net::IpAddr::V6(ref a) => (1u8, a).serialize(serializer),
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1368,6 +1368,9 @@ pub trait Serializer: Sized {
|
|||||||
///
|
///
|
||||||
/// Some formats are not intended to be human readable. For these formats
|
/// Some formats are not intended to be human readable. For these formats
|
||||||
/// a type being serialized may opt to serialize into a more compact form.
|
/// a type being serialized may opt to serialize into a more compact form.
|
||||||
|
///
|
||||||
|
/// NOTE: Implementing this method and returning `false` is considered a breaking
|
||||||
|
/// change as it may alter how any given type tries to serialize itself.
|
||||||
fn is_human_readable(&self) -> bool { true }
|
fn is_human_readable(&self) -> bool { true }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user