Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add TcpStream type to TcpListener::incoming docs #87874

Merged
merged 1 commit into from
Aug 19, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 14 additions & 7 deletions library/std/src/net/tcp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -767,17 +767,24 @@ impl TcpListener {
/// # Examples
///
/// ```no_run
/// use std::net::TcpListener;
/// use std::net::{TcpListener, TcpStream};
///
/// let listener = TcpListener::bind("127.0.0.1:80").unwrap();
/// fn handle_connection(stream: TcpStream) {
/// //...
/// }
///
/// for stream in listener.incoming() {
/// match stream {
/// Ok(stream) => {
/// println!("new client!");
/// fn main() -> std::io::Result<()> {
/// let listener = TcpListener::bind("127.0.0.1:80").unwrap();
///
/// for stream in listener.incoming() {
/// match stream {
/// Ok(stream) => {
/// handle_connection(stream);
/// }
/// Err(e) => { /* connection failed */ }
/// }
/// Err(e) => { /* connection failed */ }
/// }
/// Ok(())
/// }
/// ```
#[stable(feature = "rust1", since = "1.0.0")]
Expand Down