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

Documentation Request Revisited - try_recv behavior on empty or disconnected. #159

Open
rrichardson opened this issue Jan 7, 2025 · 0 comments

Comments

@rrichardson
Copy link

The docs for try_recv state

Attempt to fetch an incoming value from the channel associated with this receiver, returning an error if the channel is empty or if all senders have been dropped.

This is slightly misleading and it sort of indicates bad behavior on the part of the queue if there are messages in the queue but it is disconnected. The actual behavior is correct, it won't return disconnected unless the queue is empty. However, the documentation implies that it could return Disconnected even if there are items remaining in the queue.

This is an important distinction because it is not possible to build a proper system of communicating processes without such behavior.

I think it should read,

Attempt to fetch an incoming value from the channel associated with this receiver.  

Returns: 
   -  `Ok(T)`
    - `Err(Disconnected)` if the queue is empty and all `Senders` have been dropped. 
    - `Err(Empty)` if the queue is empty but the channel is not disconnected. 
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant