Skip to content

Commit

Permalink
Impl From<Ipv4Addr, Ipv6Addr> for IpAddr.
Browse files Browse the repository at this point in the history
  • Loading branch information
Yamakaky committed Dec 25, 2016
1 parent e60aa62 commit 40053a4
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/libstd/net/ip.rs
Original file line number Diff line number Diff line change
Expand Up @@ -524,6 +524,18 @@ impl fmt::Display for IpAddr {
}
}

impl From<Ipv4Addr> for IpAddr {
fn from(ipv4: Ipv4Addr) -> IpAddr {
IpAddr::V4(ipv4)
}
}

impl From<Ipv6Addr> for IpAddr {
fn from(ipv6: Ipv6Addr) -> IpAddr {
IpAddr::V6(ipv6)
}
}

#[stable(feature = "rust1", since = "1.0.0")]
impl fmt::Display for Ipv4Addr {
fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
Expand Down

0 comments on commit 40053a4

Please sign in to comment.