Struct lazyonce::LazyOnce

source ·
pub struct LazyOnce<T> { /* private fields */ }
Expand description

Wrapper type for lazy initialization

Implementations§

Get cached value, or if no value has been cached yet, compute it using the callback function.

If the callback panics, any use of the cell will panic, too.

Get cached value or None if the cell is still empty

Does not wait on the lock if the cell is being filled in

Get mutable reference to the cached value, or if no value has been cached yet, compute it using the callback function.

Assume the value has already been computed. Crash if the cell is empty.

Panics

If get() hasn’t been called yet.

Return computed value or None if the cell is empty.

Unlike try_get this returns an owned value, permanently “unwrapping” the cell.

Auto Trait Implementations§

Blanket Implementations§

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.