pub fn poll_immediate<S: Stream>(s: S) -> PollImmediate<S>
Expand description

Creates a new stream that always immediately returns Poll::Ready when awaiting it.

This is useful when immediacy is more important than waiting for the next item to be ready.


use futures::stream::{self, StreamExt};
use futures::task::Poll;

let mut r = stream::poll_immediate(Box::pin(stream::iter(1_u32..3)));
assert_eq!(, Some(Poll::Ready(1)));
assert_eq!(, Some(Poll::Ready(2)));
assert_eq!(, None);

let mut p = stream::poll_immediate(Box::pin(stream::once(async {
assert_eq!(, Some(Poll::Pending));
assert_eq!(, Some(Poll::Ready(42)));
assert_eq!(, None);