Rollup merge of #30511 - defyrlt:issue_30507, r=steveklabnik
Resolves #30507 r? @steveklabnik
This commit is contained in:
commit
8e98120780
1 changed files with 11 additions and 10 deletions
|
|
@ -27,18 +27,19 @@ use time::Duration;
|
|||
/// use std::net::UdpSocket;
|
||||
///
|
||||
/// # fn foo() -> std::io::Result<()> {
|
||||
/// let mut socket = try!(UdpSocket::bind("127.0.0.1:34254"));
|
||||
/// {
|
||||
/// let mut socket = try!(UdpSocket::bind("127.0.0.1:34254"));
|
||||
///
|
||||
/// let mut buf = [0; 10];
|
||||
/// let (amt, src) = try!(socket.recv_from(&mut buf));
|
||||
/// // read from the socket
|
||||
/// let mut buf = [0; 10];
|
||||
/// let (amt, src) = try!(socket.recv_from(&mut buf));
|
||||
///
|
||||
/// // Send a reply to the socket we received data from
|
||||
/// let buf = &mut buf[..amt];
|
||||
/// buf.reverse();
|
||||
/// try!(socket.send_to(buf, &src));
|
||||
///
|
||||
/// drop(socket); // close the socket
|
||||
/// # Ok(())
|
||||
/// // send a reply to the socket we received data from
|
||||
/// let buf = &mut buf[..amt];
|
||||
/// buf.reverse();
|
||||
/// try!(socket.send_to(buf, &src));
|
||||
/// # Ok(())
|
||||
/// } // the socket is closed here
|
||||
/// # }
|
||||
/// ```
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue