From 6c42d286b343f498ce29de2aab9358a0aedb081c Mon Sep 17 00:00:00 2001 From: Maxwell Borden Date: Sun, 26 May 2024 12:25:19 +0200 Subject: [PATCH] net: fix misleading `NamedPipeServer` example (#6590) The previous NamedPipeServer doc example seemed to imply that the return type of `NamedPipeServer::connect()` was a `Future>>`, however, `connect()` returns a `Future>>`. The following line of code reopening the pipe would shadow the newly connected pipe immediately, making the following spawned task pointless. Hopefully these changes make it more clear what should be happening in the example. --- tokio/src/net/windows/named_pipe.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tokio/src/net/windows/named_pipe.rs b/tokio/src/net/windows/named_pipe.rs index 81148482537..0b312f896f1 100644 --- a/tokio/src/net/windows/named_pipe.rs +++ b/tokio/src/net/windows/named_pipe.rs @@ -75,7 +75,8 @@ use self::doc::*; /// let server = tokio::spawn(async move { /// loop { /// // Wait for a client to connect. -/// let connected = server.connect().await?; +/// server.connect().await?; +/// let connected_client = server; /// /// // Construct the next server to be connected before sending the one /// // we already have of onto a task. This ensures that the server