Function futures_util::future::lazy
source · [−]Expand description
Creates a new future that allows delayed execution of a closure.
The provided closure is only run once the future is polled.
Examples
use futures::future;
let a = future::lazy(|_| 1);
assert_eq!(a.await, 1);
let b = future::lazy(|_| -> i32 {
panic!("oh no!")
});
drop(b); // closure is never run