pub struct LazyTransform<T, U> { /* private fields */ }
Expand description

LazyTransform<T, U> is a synchronized holder type, that holds a value of type T until it is lazily converted into a value of type U.

Implementations

Construct a new, untransformed LazyTransform<T, U> with an argument of type T.

Unwrap the contained value, returning Ok(U) if the LazyTransform<T, U> has been transformed or Err(T) if it has not.

Get a reference to the transformed value, invoking f to transform it if the LazyTransform<T, U> has yet to be transformed. It is guaranteed that if multiple calls to get_or_create race, only one will invoke its closure, and every call will receive a reference to the newly transformed value.

The closure can only ever be called once, so think carefully about what transformation you want to apply!

Get a reference to the transformed value, returning Some(&U) if the LazyTransform<T, U> has been transformed or None if it has not. It is guaranteed that if a reference is returned it is to the transformed value inside the the LazyTransform<T>.

Trait Implementations

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

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

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 resulting type after obtaining ownership.

Creates owned data from borrowed data, usually by cloning. Read more

Uses borrowed data to replace owned data, usually by cloning. Read more

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.