Function futures_lite::future::poll_fn

source ·
pub fn poll_fn<T, F>(f: F) -> PollFn<F> 
where F: FnMut(&mut Context<'_>) -> Poll<T>,
Expand description

Creates a future from a function returning Poll.

§Examples

use futures_lite::future;
use std::task::{Context, Poll};

fn f(_: &mut Context<'_>) -> Poll<i32> {
    Poll::Ready(7)
}

assert_eq!(future::poll_fn(f).await, 7);