Skip to content

Commit

Permalink
net: fix misleading NamedPipeServer example (#6590)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
Tacklebox authored May 26, 2024
1 parent 3a6fdc0 commit 6c42d28
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion tokio/src/net/windows/named_pipe.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 6c42d28

Please sign in to comment.