Skip to content

Commit 8e98120

Browse files
committed
Rollup merge of #30511 - defyrlt:issue_30507, r=steveklabnik
Resolves #30507 r? @steveklabnik
2 parents f37e69e + 45ecdc8 commit 8e98120

File tree

1 file changed

+11
-10
lines changed

1 file changed

+11
-10
lines changed

src/libstd/net/udp.rs

+11-10
Original file line numberDiff line numberDiff line change
@@ -27,18 +27,19 @@ use time::Duration;
2727
/// use std::net::UdpSocket;
2828
///
2929
/// # 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"));
3132
///
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));
3436
///
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
4243
/// # }
4344
/// ```
4445
#[stable(feature = "rust1", since = "1.0.0")]

0 commit comments

Comments
 (0)