about summary refs log tree commit diff
path: root/src/libstd/net
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2017-02-08 03:55:13 +0000
committerbors <bors@rust-lang.org>2017-02-08 03:55:13 +0000
commit10f6a5c4431e09d355a0ba319a630e02a1e38361 (patch)
tree5a5240b8b3467d3a03b7bdfd407d6c9513464124 /src/libstd/net
parentc14f87e3b0823407a91a283796bf78ef83d5fe99 (diff)
parent0a815ac816b7222554aa20b53c5fb01aa1f62616 (diff)
downloadrust-10f6a5c4431e09d355a0ba319a630e02a1e38361.tar.gz
rust-10f6a5c4431e09d355a0ba319a630e02a1e38361.zip
Auto merge of #39638 - frewsxcv:rollup, r=frewsxcv
Rollup of 13 pull requests

- Successful merges: #38764, #39361, #39372, #39374, #39400, #39426, #39431, #39459, #39482, #39545, #39593, #39620, #39621
- Failed merges:
Diffstat (limited to 'src/libstd/net')
-rw-r--r--src/libstd/net/addr.rs7
-rw-r--r--src/libstd/net/ip.rs22
2 files changed, 29 insertions, 0 deletions
diff --git a/src/libstd/net/addr.rs b/src/libstd/net/addr.rs
index 751878c687c..84c4acb8d92 100644
--- a/src/libstd/net/addr.rs
+++ b/src/libstd/net/addr.rs
@@ -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 {
diff --git a/src/libstd/net/ip.rs b/src/libstd/net/ip.rs
index 3dc89e390ee..5d6e8d319d7 100644
--- a/src/libstd/net/ip.rs
+++ b/src/libstd/net/ip.rs
@@ -656,6 +656,13 @@ impl From<[u8; 4]> for Ipv4Addr {
     }
 }
 
+#[stable(feature = "ip_from_slice", since = "1.17.0")]
+impl From<[u8; 4]> for IpAddr {
+    fn from(octets: [u8; 4]) -> IpAddr {
+        IpAddr::V4(Ipv4Addr::from(octets))
+    }
+}
+
 impl Ipv6Addr {
     /// Creates a new IPv6 address from eight 16-bit segments.
     ///
@@ -1186,6 +1193,21 @@ impl From<[u16; 8]> for Ipv6Addr {
     }
 }
 
+
+#[stable(feature = "ip_from_slice", since = "1.17.0")]
+impl From<[u8; 16]> for IpAddr {
+    fn from(octets: [u8; 16]) -> IpAddr {
+        IpAddr::V6(Ipv6Addr::from(octets))
+    }
+}
+
+#[stable(feature = "ip_from_slice", since = "1.17.0")]
+impl From<[u16; 8]> for IpAddr {
+    fn from(segments: [u16; 8]) -> IpAddr {
+        IpAddr::V6(Ipv6Addr::from(segments))
+    }
+}
+
 // Tests for this module
 #[cfg(all(test, not(target_os = "emscripten")))]
 mod tests {