pub fn poll_fn<F, T>(inner: F) -> PollFn<F>ⓘ where
F: FnMut(&mut Context<'_>) -> Poll<T>,
Creates a future from a function returning Poll
.
use futures_lite::future::block_on;
use futures_micro::poll_fn;
use std::task::{Context, Poll};
fn f(_ctx: &mut Context<'_>) -> Poll<i32> {
Poll::Ready(7)
}
assert_eq!(poll_fn(f).await, 7);