[][src]Function futures_async_combinators::stream::next

pub fn next<'a, St>(
    stream: &'a mut St
) -> impl Future<Output = Option<St::Item>> + 'a where
    St: Stream + Unpin

Creates a future that resolves to the next item in the stream.

Note that because next doesn't take ownership over the stream, the Stream type must be Unpin. If you want to use next with a !Unpin stream, you'll first have to pin the stream. This can be done by boxing the stream using Box::pin or pinning it to the stack using the pin_mut! macro from the pin_utils crate.

Examples

use futures_async_combinators::stream::{iter, next};

let mut stream = iter(1..=3);

assert_eq!(next(&mut stream).await, Some(1));
assert_eq!(next(&mut stream).await, Some(2));
assert_eq!(next(&mut stream).await, Some(3));
assert_eq!(next(&mut stream).await, None);