Struct try_lazy_init::LazyTransform [−][src]
pub struct LazyTransform<T, U> { /* fields omitted */ }
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.
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!
Panics
This method will panic if the instance has been poisoned due to a panic during a previous transformation attempt.
The method may panic (or deadlock) upon reentrance.
Try to get a reference to the transformed value, invoking a fallible 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 successfully invoke its closure, and every call will receive a
reference to the newly transformed value.
The closure can only ever be successfully called once, so think carefully about what transformation you want to apply!
Errors
Iff f
returns a Result::Err
, this error is returned verbatim.
Panics
This method will panic if the instance has been poisoned due to a panic during a previous transformation attempt.
The method may panic (or deadlock) upon reentrance.
Trait Implementations
Auto Trait Implementations
impl<T, U> !RefUnwindSafe for LazyTransform<T, U>
impl<T, U> Send for LazyTransform<T, U> where
T: Send,
U: Send,
impl<T, U> Unpin for LazyTransform<T, U> where
T: Unpin,
U: Unpin,
impl<T, U> UnwindSafe for LazyTransform<T, U> where
T: UnwindSafe,
U: UnwindSafe,
Blanket Implementations
Mutably borrows from an owned value. Read more