pub struct Lazy<T, B, F = fn() -> T> { /* private fields */ }
Expand description
A type for lazy initialization of e.g. global static variables, which
provides the same functionality as the lazy_static! macro.
impl<T, B, F> Lazy<T, B, F>
Creates a new uninitialized Lazy with the given init closure.
The init argument can be a simple function pointer or any FnOnce
closure.
use conquer_once::Lazy;
static LAZY_1: Lazy<Vec<i32>> = Lazy::new(|| vec![1, 2, 3, 4, 5]);
static LAZY_2: Lazy<Vec<i32>> = Lazy::new(Vec::<i32>::new);
Returns true if the Lazy has been successfully initialized.
Returns true if the Lazy has been poisoned.
impl<T, B, F> Lazy<T, B, F> where
B: Block,
F: FnOnce() -> T,
Returns a reference to the already initialized inner value or
initializes it first.
This has the same effect as using the Deref operator on a Lazy.
This method panics if the init procedure specified during construction
panics or if the Lazy is poisoned.
Immutably borrows from an owned value. Read more
Formats the value using the given formatter. Read more
The resulting type after dereferencing.
Formats the value using the given formatter. Read more
impl<T> Any for T where
T: 'static + ?Sized,
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more
impl<T, U> Into<U> for T where
U: From<T>,
The type returned in the event of a conversion error.
The type returned in the event of a conversion error.