From aa10b5250a8af73e2642f0e4f62570733432f1de Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Date: Thu, 16 May 2019 16:34:32 +0200 Subject: [PATCH] wire: add From
for ::std::net::IpAddr MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Marc-André Lureau --- src/wire/ip.rs | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/wire/ip.rs b/src/wire/ip.rs index 3fc85ea..16c9de6 100644 --- a/src/wire/ip.rs +++ b/src/wire/ip.rs @@ -214,6 +214,19 @@ impl From<::std::net::IpAddr> for Address { } } +#[cfg(feature = "std")] +impl From
for ::std::net::IpAddr { + fn from(x: Address) -> ::std::net::IpAddr { + match x { + #[cfg(feature = "proto-ipv4")] + Address::Ipv4(ipv4) => ::std::net::IpAddr::V4(ipv4.into()), + #[cfg(feature = "proto-ipv6")] + Address::Ipv6(ipv6) => ::std::net::IpAddr::V6(ipv6.into()), + _ => unreachable!(), + } + } +} + #[cfg(all(feature = "std", feature = "proto-ipv4"))] impl From<::std::net::Ipv4Addr> for Address { fn from(ipv4: ::std::net::Ipv4Addr) -> Address {