implement FusedStream for Receiver
fogti opened this issue · 4 comments
fogti commented
as Receiver
can detect if the channel is closed
, it probably can implement FusedStream
...
see also concurrent_queue::ConcurrentQueue::is_closed
fogti commented
impl<T> FusedStream for Receiver<T> {
fn is_terminated(&self) {
self.channel.queue.is_closed() && self.channel.queue.is_empty()
}
}
Deleted user commented
I'm curious: in what cases is FusedStream
useful or used in practice?
This sounds good - just a small correction: the Receiver
is terminated when the queue is closed and is empty.
fogti commented
It is i.a. used for using the futures::select!
macro without needing to .fuse()
the Stream
.
fogti commented
As FusedStream
is defined in futures-core
, this wouldn't even require another dependency. It would be a really small change which increases usability.