Skip to content

Commit

Permalink
add From<(I, u16)> for SocketAddr where I: Into<IpAddr>
Browse files Browse the repository at this point in the history
  • Loading branch information
seanmonstar committed Jan 31, 2017
1 parent 87dcbca commit cd603e4
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
7 changes: 7 additions & 0 deletions src/libstd/net/addr.rs
Expand Up @@ -456,6 +456,13 @@ impl From<SocketAddrV6> for SocketAddr {
}
}

#[stable(feature = "addr_from_into_ip", since = "1.17.0")]
impl<I: Into<IpAddr>> From<(I, u16)> for SocketAddr {
fn from(pieces: (I, u16)) -> SocketAddr {
SocketAddr::new(pieces.0.into(), pieces.1)
}
}

impl<'a> IntoInner<(*const c::sockaddr, c::socklen_t)> for &'a SocketAddr {
fn into_inner(self) -> (*const c::sockaddr, c::socklen_t) {
match *self {
Expand Down
4 changes: 2 additions & 2 deletions src/libstd/net/ip.rs
Expand Up @@ -1183,8 +1183,8 @@ impl From<[u8; 16]> for IpAddr {

#[stable(feature = "ip_from_slice", since = "1.17.0")]
impl From<[u16; 8]> for IpAddr {
fn from(octets: [u16; 8]) -> IpAddr {
IpAddr::V6(Ipv6Addr::from(octets))
fn from(segments: [u16; 8]) -> IpAddr {
IpAddr::V6(Ipv6Addr::from(segments))
}
}

Expand Down

0 comments on commit cd603e4

Please sign in to comment.