Skip to content

Commit 091ec88

Browse files
bors[bot]elmarco
andauthored
Merge #549
549: wire: add From<Address> for ::std::net::IpAddr r=Dirbaio a=Dirbaio Originally from #296 Co-authored-by: Marc-André Lureau <[email protected]>
2 parents 247e8d4 + 9087636 commit 091ec88

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

src/wire/ip.rs

+13
Original file line numberDiff line numberDiff line change
@@ -214,6 +214,19 @@ impl From<::std::net::IpAddr> for Address {
214214
}
215215
}
216216

217+
#[cfg(feature = "std")]
218+
impl From<Address> for ::std::net::IpAddr {
219+
fn from(x: Address) -> ::std::net::IpAddr {
220+
match x {
221+
#[cfg(feature = "proto-ipv4")]
222+
Address::Ipv4(ipv4) => ::std::net::IpAddr::V4(ipv4.into()),
223+
#[cfg(feature = "proto-ipv6")]
224+
Address::Ipv6(ipv6) => ::std::net::IpAddr::V6(ipv6.into()),
225+
_ => unreachable!(),
226+
}
227+
}
228+
}
229+
217230
#[cfg(all(feature = "std", feature = "proto-ipv4"))]
218231
impl From<::std::net::Ipv4Addr> for Address {
219232
fn from(ipv4: ::std::net::Ipv4Addr) -> Address {

0 commit comments

Comments
 (0)