Skip to content

Commit

Permalink
Fix up doc
Browse files Browse the repository at this point in the history
Signed-off-by: Fuyang Liu <[email protected]>
  • Loading branch information
liufuyang committed Dec 6, 2020
1 parent cf55e07 commit 5d72d4a
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions tokio/src/net/tcp/stream.rs
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,9 @@ impl TcpStream {

/// Turn a [`tokio::net::TcpStream`] into a [`std::net::TcpStream`].
///
/// The returned [`std::net::TcpStream`] will have `nonblocking mode` set as `true`.
/// Use [`set_nonblocking`] to change the blocking mode if needed.
///
/// # Examples
///
/// ```
Expand All @@ -206,13 +209,15 @@ impl TcpStream {
/// let (tokio_tcp_stream, _) = listener.accept().await?;
/// let mut std_tcp_stream = tokio_tcp_stream.into_std()?;
/// # handle.await.expect("The task being joined has panicked");
/// std_tcp_stream.set_nonblocking(false)?;
/// std_tcp_stream.read_exact(&mut data)?;
/// # assert_eq!(b"Hello world!", &data);
/// Ok(())
/// }
/// ```
/// [`tokio::net::TcpStream`]: TcpStream
/// [`std::net::TcpStream`]: std::net::TcpStream
/// [`set_nonblocking`]: fn@std::net::TcpStream::set_nonblocking
pub fn into_std(self) -> io::Result<std::net::TcpStream> {
#[cfg(unix)]
{
Expand Down

0 comments on commit 5d72d4a

Please sign in to comment.