diff --git a/src/libstd/net/ip.rs b/src/libstd/net/ip.rs index 6aab7486004..36a1aed8400 100644 --- a/src/libstd/net/ip.rs +++ b/src/libstd/net/ip.rs @@ -524,6 +524,18 @@ fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { } } +impl From for IpAddr { + fn from(ipv4: Ipv4Addr) -> IpAddr { + IpAddr::V4(ipv4) + } +} + +impl From 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 {