Skip to content

Commit

Permalink
Rollup merge of #97300 - ChayimFriedman2:patch-1, r=dtolnay
Browse files Browse the repository at this point in the history
Implement `FusedIterator` for `std::net::[Into]Incoming`

They never return `None`, so they trivially fulfill the contract.

What should I put for the stability attribute of `Incoming`?
  • Loading branch information
Dylan-DPC authored Jul 5, 2022
2 parents 4008dd8 + 76c0429 commit d26ccf7
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions library/std/src/net/tcp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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};
Expand Down Expand Up @@ -1009,6 +1010,9 @@ impl<'a> Iterator for Incoming<'a> {
}
}

#[stable(feature = "tcp_listener_incoming_fused_iterator", since = "1.64.0")]
impl FusedIterator for Incoming<'_> {}

#[unstable(feature = "tcplistener_into_incoming", issue = "88339")]
impl Iterator for IntoIncoming {
type Item = io::Result<TcpStream>;
Expand All @@ -1017,6 +1021,9 @@ impl Iterator for IntoIncoming {
}
}

#[unstable(feature = "tcplistener_into_incoming", issue = "88339")]
impl FusedIterator for IntoIncoming {}

impl AsInner<net_imp::TcpListener> for TcpListener {
fn as_inner(&self) -> &net_imp::TcpListener {
&self.0
Expand Down

0 comments on commit d26ccf7

Please sign in to comment.