Impl From<Ipv4Addr, Ipv6Addr> for IpAddr.

Fixes https://github.com/rust-lang/rfcs/issues/1816.
This commit is contained in:
Yamakaky 2016-12-12 15:34:09 -05:00
parent e60aa62ffe
commit 40053a46ff
No known key found for this signature in database
GPG Key ID: 1F5120C66C0B64F7

View File

@ -524,6 +524,18 @@ fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
}
}
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 {