Struct async_once_cell::unpin::ConstLazy
source · pub struct ConstLazy<T, F> { /* private fields */ }
Expand description
A value which is initialized on the first access.
Note: This structure may be larger in size than Lazy, but it does not allocate on the heap until it is first polled, so is suitable for initializing statics.
Implementations§
source§impl<T, F> ConstLazy<T, F>
impl<T, F> ConstLazy<T, F>
sourcepub const fn new(future: F) -> Self
pub const fn new(future: F) -> Self
Creates a new lazy value with the given initializing future.
sourcepub const fn with_value(value: T) -> Self
pub const fn with_value(value: T) -> Self
Creates an already-initialized lazy value.
sourcepub fn try_get(&self) -> Option<&T>
pub fn try_get(&self) -> Option<&T>
Gets the value without blocking or starting the initialization.
sourcepub fn try_get_mut(&mut self) -> Option<&mut T>
pub fn try_get_mut(&mut self) -> Option<&mut T>
Gets the value without blocking or starting the initialization.
This requires mutable access to self, so rust’s aliasing rules prevent any concurrent access and allow violating the usual rules for accessing this cell.
sourcepub fn into_value(self) -> Option<T>
pub fn into_value(self) -> Option<T>
Gets the value if it was set.