Documentation Request Revisited - try_recv behavior on empty or disconnected.
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.
```
0 条评论