From 392099337045829e31b786f12083b71ad2ad7dfc Mon Sep 17 00:00:00 2001 From: Tobias Bucher Date: Thu, 29 Sep 2016 15:46:07 +0200 Subject: [PATCH] Allow the use of `IpAddr` implementations on stable Also use the same strategy for serialization as for deserialization of `IpAddr`. Fixes #551. --- serde/src/de/impls.rs | 2 +- serde/src/ser/impls.rs | 7 ++----- 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/serde/src/de/impls.rs b/serde/src/de/impls.rs index 83a8f2c5..e7b9bb64 100644 --- a/serde/src/de/impls.rs +++ b/serde/src/de/impls.rs @@ -809,7 +809,7 @@ map_impl!( /////////////////////////////////////////////////////////////////////////////// -#[cfg(all(feature = "unstable", feature = "std"))] +#[cfg(feature = "std")] impl Deserialize for net::IpAddr { fn deserialize(deserializer: &mut D) -> Result where D: Deserializer, diff --git a/serde/src/ser/impls.rs b/serde/src/ser/impls.rs index 348c8c77..58a1683e 100644 --- a/serde/src/ser/impls.rs +++ b/serde/src/ser/impls.rs @@ -640,15 +640,12 @@ impl Serialize for Duration { /////////////////////////////////////////////////////////////////////////////// -#[cfg(all(feature = "std", feature = "unstable"))] +#[cfg(feature = "std")] impl Serialize for net::IpAddr { fn serialize(&self, serializer: &mut S) -> Result<(), S::Error> where S: Serializer, { - match *self { - net::IpAddr::V4(ref addr) => addr.serialize(serializer), - net::IpAddr::V6(ref addr) => addr.serialize(serializer), - } + self.to_string().serialize(serializer) } }