Skip to content

Commit 40053a4

Browse files
committed
Impl From<Ipv4Addr, Ipv6Addr> for IpAddr.
Fixes rust-lang/rfcs#1816.
1 parent e60aa62 commit 40053a4

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

src/libstd/net/ip.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -524,6 +524,18 @@ impl fmt::Display for IpAddr {
524524
}
525525
}
526526

527+
impl From<Ipv4Addr> for IpAddr {
528+
fn from(ipv4: Ipv4Addr) -> IpAddr {
529+
IpAddr::V4(ipv4)
530+
}
531+
}
532+
533+
impl From<Ipv6Addr> for IpAddr {
534+
fn from(ipv6: Ipv6Addr) -> IpAddr {
535+
IpAddr::V6(ipv6)
536+
}
537+
}
538+
527539
#[stable(feature = "rust1", since = "1.0.0")]
528540
impl fmt::Display for Ipv4Addr {
529541
fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {

0 commit comments

Comments
 (0)