Struct static_init::ConstLazy
source · pub struct ConstLazy<T, F = fn() -> T>(_);
Expand description
The type of const lesser lazy statics.
Statics that are initialized on first access or before main is called.
They are declared mut when the lazy is drop so that the compiler inform the coder that access to those statics are unsafe: during program destruction (after main exit) the state may be invalid.
Implementations§
source§impl<T, F> ConstLazy<T, F>
impl<T, F> ConstLazy<T, F>
sourcepub const fn new(f: F) -> Self
pub const fn new(f: F) -> Self
Initialize a lazy with a builder as argument.
Safety
This variable shall not be used as a thread_local statics or within the state of a thread_local static
sourcepub const fn as_mut_ptr(this: &Self) -> *mut T
pub const fn as_mut_ptr(this: &Self) -> *mut T
Return a pointer to the value.
The value may be in an uninitialized state.
sourcepub fn __do_init(this: &Self)where
F: FnOnce() -> T,
pub fn __do_init(this: &Self)where
F: FnOnce() -> T,
Ensure the value is initialized without optimization check
This is intended to be used at program start up by the dynamic macro.
sourcepub fn ensure_init(this: &Self)where
F: FnOnce() -> T,
pub fn ensure_init(this: &Self)where
F: FnOnce() -> T,
Ensure the value is initialized
Once this function is called, it is guaranteed that the value is in an initialized state.
This function is always called when the lazy is dereferenced.