[][src]Function smol::stream::poll_fn

pub fn poll_fn<T, F>(f: F) -> PollFn<F> where
    F: FnMut(&mut Context) -> Poll<Option<T>>, 

Creates a stream from a function returning Poll.

Examples

use futures_lite::*;
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));