diff options
| author | Guillaume Gomez <guillaume1.gomez@gmail.com> | 2016-12-07 18:28:07 -0800 |
|---|---|---|
| committer | Guillaume Gomez <guillaume1.gomez@gmail.com> | 2016-12-08 09:43:38 -0800 |
| commit | a78a33c52a3a4766e170a8dbe0328cbbd03d4f14 (patch) | |
| tree | c6453620b8d3c977255bc8f914c4004bbbf23c11 /src/libstd/sys | |
| parent | c35b9f6703e11e08d5250434472b36a109353cc3 (diff) | |
| download | rust-a78a33c52a3a4766e170a8dbe0328cbbd03d4f14.tar.gz rust-a78a33c52a3a4766e170a8dbe0328cbbd03d4f14.zip | |
Add Incoming doc examples
Diffstat (limited to 'src/libstd/sys')
| -rw-r--r-- | src/libstd/sys/unix/ext/net.rs | 33 |
1 files changed, 30 insertions, 3 deletions
diff --git a/src/libstd/sys/unix/ext/net.rs b/src/libstd/sys/unix/ext/net.rs index f346e3eb44f..d49f9343b0e 100644 --- a/src/libstd/sys/unix/ext/net.rs +++ b/src/libstd/sys/unix/ext/net.rs @@ -791,9 +791,36 @@ impl<'a> IntoIterator for &'a UnixListener { } } -/// An iterator over incoming connections to a `UnixListener`. +/// An iterator over incoming connections to a [`UnixListener`]. /// -/// It will never return `None`. +/// It will never return [`None`]. +/// +/// [`None`]: ../../std/option/enum.Option.html#variant.None +/// [`UnixListener`]: struct.UnixListener.html +/// +/// # Examples +/// +/// ```no_run +/// use std::thread; +/// use std::os::unix::net::{UnixStream, UnixListener}; +/// +/// fn handle_client(stream: UnixStream) { +/// // ... +/// } +/// +/// let listener = UnixListener::bind("/path/to/the/socket").unwrap(); +/// +/// for stream in listener.incoming() { +/// match stream { +/// Ok(stream) => { +/// thread::spawn(|| handle_client(stream)); +/// } +/// Err(err) => { +/// break; +/// } +/// } +/// } +/// ``` #[derive(Debug)] #[stable(feature = "unix_socket", since = "1.10.0")] pub struct Incoming<'a> { @@ -817,7 +844,7 @@ impl<'a> Iterator for Incoming<'a> { /// /// # Examples /// -/// ```rust,no_run +/// ```no_run /// use std::os::unix::net::UnixDatagram; /// /// let socket = UnixDatagram::bind("/path/to/my/socket").unwrap(); |
