Skip to content

Commit

Permalink
net: fix flaky doctest for TcpStream::into_std (#6074)
Browse files Browse the repository at this point in the history
  • Loading branch information
Darksonn authored Oct 14, 2023
1 parent 339c78a commit 1134cbb
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions tokio/src/net/tcp/stream.rs
Original file line number Diff line number Diff line change
Expand Up @@ -222,10 +222,14 @@ impl TcpStream {
/// #[tokio::main]
/// async fn main() -> Result<(), Box<dyn Error>> {
/// let mut data = [0u8; 12];
/// # if false {
/// let listener = TcpListener::bind("127.0.0.1:34254").await?;
/// # let handle = tokio::spawn(async {
/// # let mut stream: TcpStream = TcpStream::connect("127.0.0.1:34254").await.unwrap();
/// # stream.write(b"Hello world!").await.unwrap();
/// # }
/// # let listener = TcpListener::bind("127.0.0.1:0").await?;
/// # let addr = listener.local_addr().unwrap();
/// # let handle = tokio::spawn(async move {
/// # let mut stream: TcpStream = TcpStream::connect(addr).await.unwrap();
/// # stream.write_all(b"Hello world!").await.unwrap();
/// # });
/// let (tokio_tcp_stream, _) = listener.accept().await?;
/// let mut std_tcp_stream = tokio_tcp_stream.into_std()?;
Expand Down

0 comments on commit 1134cbb

Please sign in to comment.