Skip to content

Commit cada869

Browse files
authored
Rollup merge of rust-lang#41526 - steveklabnik:gh35950, r=GuillaumeGomez
Clean up TcpStream example Fixes rust-lang#35950
2 parents 2d91292 + 7b7fe9b commit cada869

File tree

1 file changed

+8
-9
lines changed

1 file changed

+8
-9
lines changed

src/libstd/net/tcp.rs

+8-9
Original file line numberDiff line numberDiff line change
@@ -72,24 +72,23 @@ pub struct TcpStream(net_imp::TcpStream);
7272
///
7373
/// # Examples
7474
///
75-
/// ```no_run
75+
/// ```
76+
/// # use std::io;
7677
/// use std::net::{TcpListener, TcpStream};
7778
///
78-
/// let listener = TcpListener::bind("127.0.0.1:80").unwrap();
79-
///
8079
/// fn handle_client(stream: TcpStream) {
8180
/// // ...
8281
/// }
8382
///
83+
/// # fn process() -> io::Result<()> {
84+
/// let listener = TcpListener::bind("127.0.0.1:80").unwrap();
85+
///
8486
/// // accept connections and process them serially
8587
/// for stream in listener.incoming() {
86-
/// match stream {
87-
/// Ok(stream) => {
88-
/// handle_client(stream);
89-
/// }
90-
/// Err(e) => { /* connection failed */ }
91-
/// }
88+
/// handle_client(stream?);
9289
/// }
90+
/// # Ok(())
91+
/// # }
9392
/// ```
9493
#[stable(feature = "rust1", since = "1.0.0")]
9594
pub struct TcpListener(net_imp::TcpListener);

0 commit comments

Comments
 (0)