Feature gate: #![feature(future_lazy)]
This is a tracking issue for core::future::{lazy, Lazy}, which executes a closure the first time it is polled:
let a = std::future::lazy(|_| 1);
assert_eq!(a.await, 1);
Public API
// core::future
pub struct Lazy<F> {
f: Option<F>,
}
pub fn lazy<F, R>(f: F) -> Lazy<F>
where
F: FnOnce(&mut Context<'_>) -> R,
{
// ..
}
impl<F, R> Future for Lazy<F>
where
F: FnOnce(&mut Context<'_>) -> R,
{
type Output = R;
// ...
}
Steps / History
Unresolved Questions
Feature gate:
#![feature(future_lazy)]This is a tracking issue for
core::future::{lazy, Lazy}, which executes a closure the first time it is polled:Public API
Steps / History
core::future::lazy#91648Unresolved Questions