sync: clarify that recv returns None once closed and no more messages (#7920)

The previous documentation stated:
  'As such, Receiver::poll returns Ok(Ready(None))'

This was misleading: when all Sender handles are dropped, recv does NOT
immediately return None. Buffered messages already in the channel can
still be received. Only after all senders are dropped AND the channel
has been fully drained does recv return None.

Also update the method reference from the internal Receiver::poll to the
public API: Receiver::recv and Receiver::poll_recv.

Closes #6053
This commit is contained in:
Maxime Grenu
2026-02-20 08:34:11 +00:00
committed by GitHub
parent e65040f061
commit 09f92b5aed
+3 -1
View File
@@ -29,7 +29,9 @@
//!
//! When all [`Sender`] handles have been dropped, it is no longer
//! possible to send values into the channel. This is considered the termination
//! event of the stream. As such, `Receiver::poll` returns `Ok(Ready(None))`.
//! event of the stream. Once all senders have been dropped and any remaining
//! buffered values have been received, `Receiver::recv` returns `None`
//! (and `Receiver::poll_recv` returns `Poll::Ready(None)`).
//!
//! If the [`Receiver`] handle is dropped, then messages can no longer
//! be read out of the channel. In this case, all further attempts to send will