Skip to content

Commit 6c42d28

Browse files
authored
net: fix misleading NamedPipeServer example (#6590)
The previous NamedPipeServer doc example seemed to imply that the return type of `NamedPipeServer::connect()` was a `Future<Result<some_kind_of_client>>>`, however, `connect()` returns a `Future<Result<()>>>`. 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.
1 parent 3a6fdc0 commit 6c42d28

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

tokio/src/net/windows/named_pipe.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,8 @@ use self::doc::*;
7575
/// let server = tokio::spawn(async move {
7676
/// loop {
7777
/// // Wait for a client to connect.
78-
/// let connected = server.connect().await?;
78+
/// server.connect().await?;
79+
/// let connected_client = server;
7980
///
8081
/// // Construct the next server to be connected before sending the one
8182
/// // we already have of onto a task. This ensures that the server

0 commit comments

Comments
 (0)