Merge pull request #568 from tbu-/pr_ipaddr_stable

Allow the use of `IpAddr` implementations on stable
This commit is contained in:
David Tolnay 2016-09-29 08:58:33 -07:00 committed by GitHub
commit 9970084550
2 changed files with 3 additions and 6 deletions

View File

@ -809,7 +809,7 @@ map_impl!(
///////////////////////////////////////////////////////////////////////////////
#[cfg(all(feature = "unstable", feature = "std"))]
#[cfg(feature = "std")]
impl Deserialize for net::IpAddr {
fn deserialize<D>(deserializer: &mut D) -> Result<Self, D::Error>
where D: Deserializer,

View File

@ -640,15 +640,12 @@ impl Serialize for Duration {
///////////////////////////////////////////////////////////////////////////////
#[cfg(all(feature = "std", feature = "unstable"))]
#[cfg(feature = "std")]
impl Serialize for net::IpAddr {
fn serialize<S>(&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)
}
}