Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix misleading NamedPipeServer example #6590

Merged
merged 1 commit into from
May 26, 2024

Conversation

Tacklebox
Copy link
Contributor

Motivation

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.

Solution

Instead, now it binds the original named pipe to a new variable after a client connects, allowing for the subsequent task to be able use the connection.

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.
@Darksonn Darksonn added T-docs Topic: documentation A-tokio Area: The main tokio crate M-net Module: tokio/net labels May 26, 2024
Copy link
Contributor

@Darksonn Darksonn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you.

@Darksonn Darksonn merged commit 6c42d28 into tokio-rs:master May 26, 2024
82 of 87 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-tokio Area: The main tokio crate M-net Module: tokio/net T-docs Topic: documentation
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants