File tree 1 file changed +11
-10
lines changed
1 file changed +11
-10
lines changed Original file line number Diff line number Diff line change @@ -27,18 +27,19 @@ use time::Duration;
27
27
/// use std::net::UdpSocket;
28
28
///
29
29
/// # fn foo() -> std::io::Result<()> {
30
- /// let mut socket = try!(UdpSocket::bind("127.0.0.1:34254"));
30
+ /// {
31
+ /// let mut socket = try!(UdpSocket::bind("127.0.0.1:34254"));
31
32
///
32
- /// let mut buf = [0; 10];
33
- /// let (amt, src) = try!(socket.recv_from(&mut buf));
33
+ /// // read from the socket
34
+ /// let mut buf = [0; 10];
35
+ /// let (amt, src) = try!(socket.recv_from(&mut buf));
34
36
///
35
- /// // Send a reply to the socket we received data from
36
- /// let buf = &mut buf[..amt];
37
- /// buf.reverse();
38
- /// try!(socket.send_to(buf, &src));
39
- ///
40
- /// drop(socket); // close the socket
41
- /// # Ok(())
37
+ /// // send a reply to the socket we received data from
38
+ /// let buf = &mut buf[..amt];
39
+ /// buf.reverse();
40
+ /// try!(socket.send_to(buf, &src));
41
+ /// # Ok(())
42
+ /// } // the socket is closed here
42
43
/// # }
43
44
/// ```
44
45
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
You can’t perform that action at this time.
0 commit comments