File tree 1 file changed +30
-3
lines changed
1 file changed +30
-3
lines changed Original file line number Diff line number Diff line change @@ -791,9 +791,36 @@ impl<'a> IntoIterator for &'a UnixListener {
791
791
}
792
792
}
793
793
794
- /// An iterator over incoming connections to a `UnixListener`.
794
+ /// An iterator over incoming connections to a [ `UnixListener`] .
795
795
///
796
- /// It will never return `None`.
796
+ /// It will never return [`None`].
797
+ ///
798
+ /// [`None`]: ../../std/option/enum.Option.html#variant.None
799
+ /// [`UnixListener`]: struct.UnixListener.html
800
+ ///
801
+ /// # Examples
802
+ ///
803
+ /// ```no_run
804
+ /// use std::thread;
805
+ /// use std::os::unix::net::{UnixStream, UnixListener};
806
+ ///
807
+ /// fn handle_client(stream: UnixStream) {
808
+ /// // ...
809
+ /// }
810
+ ///
811
+ /// let listener = UnixListener::bind("/path/to/the/socket").unwrap();
812
+ ///
813
+ /// for stream in listener.incoming() {
814
+ /// match stream {
815
+ /// Ok(stream) => {
816
+ /// thread::spawn(|| handle_client(stream));
817
+ /// }
818
+ /// Err(err) => {
819
+ /// break;
820
+ /// }
821
+ /// }
822
+ /// }
823
+ /// ```
797
824
#[ derive( Debug ) ]
798
825
#[ stable( feature = "unix_socket" , since = "1.10.0" ) ]
799
826
pub struct Incoming < ' a > {
@@ -817,7 +844,7 @@ impl<'a> Iterator for Incoming<'a> {
817
844
///
818
845
/// # Examples
819
846
///
820
- /// ```rust, no_run
847
+ /// ```no_run
821
848
/// use std::os::unix::net::UnixDatagram;
822
849
///
823
850
/// let socket = UnixDatagram::bind("/path/to/my/socket").unwrap();
You can’t perform that action at this time.
0 commit comments