From 369555c85a038d4cad396301822cf89627a7e5c6 Mon Sep 17 00:00:00 2001 From: Chayim Refael Friedman Date: Mon, 23 May 2022 02:33:27 +0000 Subject: [PATCH 1/2] Implement `FusedIterator` for `std::net::[Into]Incoming` They never return `None`, so they trivially fulfill the contract. --- library/std/src/net/tcp.rs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/library/std/src/net/tcp.rs b/library/std/src/net/tcp.rs index 06300035633b9..2cbc9f22baf78 100644 --- a/library/std/src/net/tcp.rs +++ b/library/std/src/net/tcp.rs @@ -7,6 +7,7 @@ use crate::io::prelude::*; use crate::fmt; use crate::io::{self, IoSlice, IoSliceMut}; +use crate::iter::FusedIterator; use crate::net::{Shutdown, SocketAddr, ToSocketAddrs}; use crate::sys_common::net as net_imp; use crate::sys_common::{AsInner, FromInner, IntoInner}; @@ -1009,6 +1010,9 @@ impl<'a> Iterator for Incoming<'a> { } } +#[stable(feature = "tcp_listener_incoming_fused_iterator", since = "1.63.0")] +impl FusedIterator for Incoming<'_> {} + #[unstable(feature = "tcplistener_into_incoming", issue = "88339")] impl Iterator for IntoIncoming { type Item = io::Result; @@ -1017,6 +1021,9 @@ impl Iterator for IntoIncoming { } } +#[unstable(feature = "tcplistener_into_incoming", issue = "88339")] +impl FusedIterator for IntoIncoming {} + impl AsInner for TcpListener { fn as_inner(&self) -> &net_imp::TcpListener { &self.0 From 76c0429d86041665dcf05682cd6579d8d2ab153c Mon Sep 17 00:00:00 2001 From: David Tolnay Date: Sat, 2 Jul 2022 11:02:54 -0700 Subject: [PATCH 2/2] Bump std::net::Incoming FusedIterator impl to Rust 1.64 --- library/std/src/net/tcp.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/library/std/src/net/tcp.rs b/library/std/src/net/tcp.rs index 2cbc9f22baf78..69b72a81c5b6d 100644 --- a/library/std/src/net/tcp.rs +++ b/library/std/src/net/tcp.rs @@ -1010,7 +1010,7 @@ impl<'a> Iterator for Incoming<'a> { } } -#[stable(feature = "tcp_listener_incoming_fused_iterator", since = "1.63.0")] +#[stable(feature = "tcp_listener_incoming_fused_iterator", since = "1.64.0")] impl FusedIterator for Incoming<'_> {} #[unstable(feature = "tcplistener_into_incoming", issue = "88339")]