futures_lite::streamFunction poll_fn
source pub fn poll_fn<T, F>(f: F) -> PollFn<F>
Expand description
Creates a stream from a function returning Poll
.
ยงExamples
use futures_lite::stream::{self, StreamExt};
use std::task::{Context, Poll};
fn f(_: &mut Context<'_>) -> Poll<Option<i32>> {
Poll::Ready(Some(7))
}
assert_eq!(stream::poll_fn(f).next().await, Some(7));