[][src]Function ufut::poll_fn

pub fn poll_fn<F, T>(inner: F) -> PollFn<F>

Notable traits for PollFn<F>

impl<F, T> Future for PollFn<F> where
    F: FnMut(&mut Context<'_>) -> Poll<T>, 
type Output = T;
where
    F: FnMut(&mut Context<'_>) -> Poll<T>, 

Creates a future from a function returning Poll.

Examples

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);