mirror of
https://github.com/rust-lang/rust.git
synced 2025-02-22 03:44:24 +00:00
Rollup merge of #41526 - steveklabnik:gh35950, r=GuillaumeGomez
Clean up TcpStream example Fixes #35950
This commit is contained in:
commit
095936c209
@ -72,24 +72,23 @@ pub struct TcpStream(net_imp::TcpStream);
|
||||
///
|
||||
/// # Examples
|
||||
///
|
||||
/// ```no_run
|
||||
/// ```
|
||||
/// # use std::io;
|
||||
/// use std::net::{TcpListener, TcpStream};
|
||||
///
|
||||
/// let listener = TcpListener::bind("127.0.0.1:80").unwrap();
|
||||
///
|
||||
/// fn handle_client(stream: TcpStream) {
|
||||
/// // ...
|
||||
/// }
|
||||
///
|
||||
/// # fn process() -> io::Result<()> {
|
||||
/// let listener = TcpListener::bind("127.0.0.1:80").unwrap();
|
||||
///
|
||||
/// // accept connections and process them serially
|
||||
/// for stream in listener.incoming() {
|
||||
/// match stream {
|
||||
/// Ok(stream) => {
|
||||
/// handle_client(stream);
|
||||
/// }
|
||||
/// Err(e) => { /* connection failed */ }
|
||||
/// }
|
||||
/// handle_client(stream?);
|
||||
/// }
|
||||
/// # Ok(())
|
||||
/// # }
|
||||
/// ```
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
pub struct TcpListener(net_imp::TcpListener);
|
||||
|
Loading…
Reference in New Issue
Block a user