pub async fn future_fn<T, F>(fn_: F) -> TExpand description
Implements a Future from a closure.
ยงExamples
A future that is ready with a closure returns Some(R).
use std::task::Poll;
use zng_task as task;
async fn ready_some<R>(mut closure: impl FnMut() -> Option<R>) -> R {
task::future_fn(|cx| match closure() {
Some(r) => Poll::Ready(r),
None => Poll::Pending,
})
.await
}