diff options
| author | Nick Cameron <ncameron@mozilla.com> | 2014-09-26 17:48:16 +1200 |
|---|---|---|
| committer | Nick Cameron <ncameron@mozilla.com> | 2014-10-07 15:49:53 +1300 |
| commit | 2d3823441fe5324f747f7bf51ffc07b9434f827f (patch) | |
| tree | cf8f7d36282f850bee8aaa73521499fe6f436f85 /src/libstd/io | |
| parent | 59976942eacd26c0cc37247c3ac0c78b97edc6ea (diff) | |
| download | rust-2d3823441fe5324f747f7bf51ffc07b9434f827f.tar.gz rust-2d3823441fe5324f747f7bf51ffc07b9434f827f.zip | |
Put slicing syntax behind a feature gate.
[breaking-change] If you are using slicing syntax you will need to add #![feature(slicing_syntax)] to your crate.
Diffstat (limited to 'src/libstd/io')
| -rw-r--r-- | src/libstd/io/net/udp.rs | 33 |
1 files changed, 18 insertions, 15 deletions
diff --git a/src/libstd/io/net/udp.rs b/src/libstd/io/net/udp.rs index 4dd6f448ee5..b8fb187548c 100644 --- a/src/libstd/io/net/udp.rs +++ b/src/libstd/io/net/udp.rs @@ -35,26 +35,29 @@ use rt::rtio; /// /// ```rust,no_run /// # #![allow(unused_must_use)] +/// #![feature(slicing_syntax)] +/// /// use std::io::net::udp::UdpSocket; /// use std::io::net::ip::{Ipv4Addr, SocketAddr}; +/// fn main() { +/// let addr = SocketAddr { ip: Ipv4Addr(127, 0, 0, 1), port: 34254 }; +/// let mut socket = match UdpSocket::bind(addr) { +/// Ok(s) => s, +/// Err(e) => fail!("couldn't bind socket: {}", e), +/// }; /// -/// let addr = SocketAddr { ip: Ipv4Addr(127, 0, 0, 1), port: 34254 }; -/// let mut socket = match UdpSocket::bind(addr) { -/// Ok(s) => s, -/// Err(e) => fail!("couldn't bind socket: {}", e), -/// }; -/// -/// let mut buf = [0, ..10]; -/// match socket.recv_from(buf) { -/// Ok((amt, src)) => { -/// // Send a reply to the socket we received data from -/// let buf = buf[mut ..amt]; -/// buf.reverse(); -/// socket.send_to(buf, src); +/// let mut buf = [0, ..10]; +/// match socket.recv_from(buf) { +/// Ok((amt, src)) => { +/// // Send a reply to the socket we received data from +/// let buf = buf[mut ..amt]; +/// buf.reverse(); +/// socket.send_to(buf, src); +/// } +/// Err(e) => println!("couldn't receive a datagram: {}", e) /// } -/// Err(e) => println!("couldn't receive a datagram: {}", e) +/// drop(socket); // close the socket /// } -/// drop(socket); // close the socket /// ``` pub struct UdpSocket { obj: Box<RtioUdpSocket + Send>, |
