pub struct Lazy<T, G = fn() -> T> { /* private fields */ }
Expand description

A type that initialize itself only once on the first access

Implementations

Build a new static object

Safety

This function may be unsafe if building any thing else than a thread local object or a static will be the cause of undefined behavior

Build a new static object with debug information

Safety

This function may be unsafe if building any thing else than a thread local object or a static will be the cause of undefined behavior

Initialize if necessary then return a reference to the target.

Panics

Panic if previous attempt to initialize has panicked and the lazy policy does not tolorate further initialization attempt or if initialization panic.

Return a reference to the target if initialized otherwise return an error.

Initialize and return a mutable reference to the target

This method is extremly efficient as it does not requires any form of locking when initializing

Return a mutable reference to the target if initialized otherwise return an error.

This method is extremly efficient as it does not requires any form of locking when initializing

Return the phase

Initialize the lazy if not yet initialized

Panic

Panic if the generator panics

Trait Implementations

Formats the value using the given formatter. Read more

Returns the “default value” for a type. Read more

The resulting type after dereferencing.

Dereferences the value.

Mutably dereferences the value.

Executes the destructor for this type. Read more

Initialize if necessary then return a reference to the target. Read more

Return a reference to the target if initialized otherwise return an error.

The current phase of the static

Initialize the static if there were no previous attempt to initialize it.

return the current phase

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.