From 7ea0abfb3557da792d3d743473463e26cf3aeebf Mon Sep 17 00:00:00 2001 From: Steven Fackler Date: Sun, 24 Jan 2016 00:31:22 -0800 Subject: [PATCH] Implement ToSocketAddrs for &[SocketAddr] --- src/libstd/net/addr.rs | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/libstd/net/addr.rs b/src/libstd/net/addr.rs index 9382793b8be..c592bef4980 100644 --- a/src/libstd/net/addr.rs +++ b/src/libstd/net/addr.rs @@ -21,6 +21,8 @@ use option; use sys::net::netc as c; use sys_common::{FromInner, AsInner, IntoInner}; use vec; +use iter; +use slice; /// Representation of a socket address for networking applications. /// @@ -457,6 +459,15 @@ impl ToSocketAddrs for str { } } +#[stable(feature = "slice_to_socket_addrs", since = "1.8.0")] +impl<'a> ToSocketAddrs for &'a [SocketAddr] { + type Iter = iter::Cloned>; + + fn to_socket_addrs(&self) -> io::Result { + Ok(self.iter().cloned()) + } +} + #[stable(feature = "rust1", since = "1.0.0")] impl<'a, T: ToSocketAddrs + ?Sized> ToSocketAddrs for &'a T { type Iter = T::Iter;