Skip to content

Conversation

petrosagg
Copy link
Contributor

I noticed that is_terminated() returns true only after a None value has been observed from the stream. The documentation ofFusedStream allows this method to return true earlier, if the stream can no longer make progress:

Usually, this state occurs after poll_next (or try_poll_next) returned Poll::Ready(None). However, is_terminated may also return true if a stream has become inactive and can no longer make progress and should be ignored or dropped rather than being polled again.

This PR was prompted by a use case that wants to see if the channel has more things to give out without actually pulling them out of the stream since the place of checking is not the right place to handle a potential element from the stream.

This effectively makes .is_terminated() behave like tokio::sync::mpsc::UnboundedReceiver::is_closed().

@rustbot rustbot added A-channel Area: futures::channel S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Sep 16, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-channel Area: futures::channel S-waiting-on-review Status: Awaiting review from the assignee but also interested parties.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants