impl Future for stream::{Buffered, BufferUnordered, FuturesOrdered} #2677
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This enables
poll()
ing to fill the buffer without producing or consuming the Stream's outputs.Buffered
andFuturesOrdered
will also poll their inner futures produced by the stream, since they have an output value buffer available.BufferUnordered
however will only poll the underlying stream, as it cannot produce outputs without consuming them.Given that theOutput
of theBufferUnordered
impl isn't particularly useful (because it doesn't indicate anything about the futures produced by the stream), maybe it should betype Output = Infallible
, and never complete?For the other two, the completion is more meaningful as it indicates that the stream is empty and that all captured futures have produced outputs (though in the case of
Buffered
, it will stall while the buffer remains full).It may also make sense to expose this as apoll_stream()
function rather thanimpl Future
(or otherwise aIntoFuture for &Self
or something), for the sake of extension trait method resolution.EDIT: moved to inherent
poll_stream()
instead, see latest commit. Final name tbd (buffered.poll_all()
?poll_buffer()
?poll_fill()
?)