Skip to content
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