Impl From<inner> for IpAddr and SocketAddr.
Fixes https://github.com/rust-lang/rfcs/issues/1816.
This commit is contained in:
parent
40053a46ff
commit
2d365c6b7a
@ -446,6 +446,20 @@ fn from_inner(addr: c::sockaddr_in6) -> SocketAddrV6 {
|
||||
}
|
||||
}
|
||||
|
||||
#[stable(feature = "ip_from_ip", since = "1.16.0")]
|
||||
impl From<SocketAddrV4> for SocketAddr {
|
||||
fn from(sock4: SocketAddrV4) -> SocketAddr {
|
||||
SocketAddr::V4(sock4)
|
||||
}
|
||||
}
|
||||
|
||||
#[stable(feature = "ip_from_ip", since = "1.16.0")]
|
||||
impl From<SocketAddrV6> for SocketAddr {
|
||||
fn from(sock6: SocketAddrV6) -> SocketAddr {
|
||||
SocketAddr::V6(sock6)
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a> IntoInner<(*const c::sockaddr, c::socklen_t)> for &'a SocketAddr {
|
||||
fn into_inner(self) -> (*const c::sockaddr, c::socklen_t) {
|
||||
match *self {
|
||||
|
@ -524,12 +524,14 @@ fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
|
||||
}
|
||||
}
|
||||
|
||||
#[stable(feature = "ip_from_ip", since = "1.16.0")]
|
||||
impl From<Ipv4Addr> for IpAddr {
|
||||
fn from(ipv4: Ipv4Addr) -> IpAddr {
|
||||
IpAddr::V4(ipv4)
|
||||
}
|
||||
}
|
||||
|
||||
#[stable(feature = "ip_from_ip", since = "1.16.0")]
|
||||
impl From<Ipv6Addr> for IpAddr {
|
||||
fn from(ipv6: Ipv6Addr) -> IpAddr {
|
||||
IpAddr::V6(ipv6)
|
||||
|
Loading…
Reference in New Issue
Block a user