Skip to content

Commit 1636910

Browse files
authored
net: impl ToSocketAddrs for &[SocketAddr] (#2604)
1 parent adaa684 commit 1636910

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

tokio/src/net/addr.rs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,20 @@ impl sealed::ToSocketAddrsPriv for (Ipv6Addr, u16) {
121121
}
122122
}
123123

124+
// ===== impl &[SocketAddr] =====
125+
126+
impl ToSocketAddrs for &[SocketAddr] {}
127+
128+
impl sealed::ToSocketAddrsPriv for &[SocketAddr] {
129+
type Iter = std::vec::IntoIter<SocketAddr>;
130+
type Future = ReadyFuture<Self::Iter>;
131+
132+
fn to_socket_addrs(&self) -> Self::Future {
133+
let iter = self.to_vec().into_iter();
134+
future::ok(iter)
135+
}
136+
}
137+
124138
cfg_dns! {
125139
// ===== impl str =====
126140

0 commit comments

Comments
 (0)