diff options
| author | Huon Wilson <dbau.pp+github@gmail.com> | 2014-04-11 20:18:19 +1000 |
|---|---|---|
| committer | Huon Wilson <dbau.pp+github@gmail.com> | 2014-04-11 23:10:22 +1000 |
| commit | 5b109a175459e6428dafdd6aa5bedc6f598a3dff (patch) | |
| tree | 394de554cba4592a1ceb3bd8ed1b5f4091101625 /src/libstd/io/net/tcp.rs | |
| parent | 0156af156d70efd5a3c96d0c5b8fc9bec39a7ae5 (diff) | |
| download | rust-5b109a175459e6428dafdd6aa5bedc6f598a3dff.tar.gz rust-5b109a175459e6428dafdd6aa5bedc6f598a3dff.zip | |
Add more type signatures to the docs; tweak a few of them.
Someone reading the docs won't know what the types of various things are, so this adds them in a few meaningful places to help with comprehension. cc #13423.
Diffstat (limited to 'src/libstd/io/net/tcp.rs')
| -rw-r--r-- | src/libstd/io/net/tcp.rs | 24 |
1 files changed, 15 insertions, 9 deletions
diff --git a/src/libstd/io/net/tcp.rs b/src/libstd/io/net/tcp.rs index 02c061c54dd..2253b22796f 100644 --- a/src/libstd/io/net/tcp.rs +++ b/src/libstd/io/net/tcp.rs @@ -100,10 +100,10 @@ impl Writer for TcpStream { /// # Example /// /// ```rust -/// # fn main() {} +/// # fn main() { } /// # fn foo() { -/// # #[allow(unused_must_use, dead_code)]; -/// use std::io::net::tcp::TcpListener; +/// # #![allow(dead_code)] +/// use std::io::{TcpListener, TcpStream}; /// use std::io::net::ip::{Ipv4Addr, SocketAddr}; /// use std::io::{Acceptor, Listener}; /// @@ -113,12 +113,19 @@ impl Writer for TcpStream { /// // bind the listener to the specified address /// let mut acceptor = listener.listen(); /// -/// // accept connections and process them -/// # fn handle_client<T>(_: T) {} +/// fn handle_client(mut stream: TcpStream) { +/// // ... +/// # &mut stream; // silence unused mutability/variable warning +/// } +/// // accept connections and process them, spawning a new tasks for each one /// for stream in acceptor.incoming() { -/// spawn(proc() { -/// handle_client(stream); -/// }); +/// match stream { +/// Err(e) => { /* connection failed */ } +/// Ok(stream) => spawn(proc() { +/// // connection succeeded +/// handle_client(stream) +/// }) +/// } /// } /// /// // close the socket server @@ -728,4 +735,3 @@ mod test { assert_eq!(s.read_to_end(), Ok(vec!(1))); }) } - |
