File tree Expand file tree Collapse file tree 1 file changed +14
-7
lines changed Expand file tree Collapse file tree 1 file changed +14
-7
lines changed Original file line number Diff line number Diff line change @@ -767,17 +767,24 @@ impl TcpListener {
767
767
/// # Examples
768
768
///
769
769
/// ```no_run
770
- /// use std::net::TcpListener;
770
+ /// use std::net::{ TcpListener, TcpStream} ;
771
771
///
772
- /// let listener = TcpListener::bind("127.0.0.1:80").unwrap();
772
+ /// fn handle_connection(stream: TcpStream) {
773
+ /// //...
774
+ /// }
773
775
///
774
- /// for stream in listener.incoming() {
775
- /// match stream {
776
- /// Ok(stream) => {
777
- /// println!("new client!");
776
+ /// fn main() -> std::io::Result<()> {
777
+ /// let listener = TcpListener::bind("127.0.0.1:80").unwrap();
778
+ ///
779
+ /// for stream in listener.incoming() {
780
+ /// match stream {
781
+ /// Ok(stream) => {
782
+ /// handle_connection(stream);
783
+ /// }
784
+ /// Err(e) => { /* connection failed */ }
778
785
/// }
779
- /// Err(e) => { /* connection failed */ }
780
786
/// }
787
+ /// Ok(())
781
788
/// }
782
789
/// ```
783
790
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
You can’t perform that action at this time.
0 commit comments