Struct thunk::sync::ArcThunk
[−]
[src]
pub struct ArcThunk<'a, T: 'a>(_);
An Arc
-wrapped AtomicThunk
which implements LazyRef
.
Methods
impl<'a, T: 'a> ArcThunk<'a, T>
[src]
fn try_unwrap(this: ArcThunk<'a, T>) -> Result<T, ArcThunk<'a, T>>
If the ArcThunk
is unevaluated, this will force it. If the RcThunk
is
the sole, unique owner of the underlying thunk, this will return the forced
value; otherwise, it will return an Err
containing the original ArcThunk
.
fn get_mut<'b>(this: &'b mut ArcThunk<'a, T>) -> Option<&'b mut T>
If the ArcThunk
is unevaluated, this will force it. If the RcThunk
is
the sole, unique owner of the underlying thunk, this will return a
mutable reference to the forced value; otherwise, it will return None
.
fn make_mut<'b>(this: &'b mut ArcThunk<'a, T>) -> &'b mut T where
T: Clone,
T: Clone,
If the ArcThunk
is unevaluated, this will force it. If the RcThunk
is the sole, unique owner of the underlying thunk, this will return a
mutable reference to the forced value; if it is not, then it will clone
the forced value and return a mutable reference to the newly cloned
value. The &mut ArcThunk
passed in will be updated to reference the
newly cloned value.
Trait Implementations
impl<'a, T: 'a> Clone for ArcThunk<'a, T>
[src]
fn clone(&self) -> ArcThunk<'a, T>
Returns a copy of the value. Read more
fn clone_from(&mut self, source: &Self)
1.0.0
Performs copy-assignment from source
. Read more
impl<'a, T: 'a> AsRef<T> for ArcThunk<'a, T>
[src]
fn as_ref(&self) -> &T
Performs the conversion.
impl<'a, T: 'a> Deref for ArcThunk<'a, T>
[src]
type Target = T
The resulting type after dereferencing
fn deref(&self) -> &T
The method called to dereference a value
impl<'a, T: 'a> From<T> for ArcThunk<'a, T>
[src]
impl<'a, T: 'a> LazyRef<'a> for ArcThunk<'a, T>
[src]
fn defer<F: FnOnce() -> T + 'a>(f: F) -> ArcThunk<'a, T>
Defer a computation stored as a FnOnce
closure. Unwrapping/dereferencing will force the computation of the closure. Read more
fn force(&self)
Manually force a thunk's computation.
fn computed(t: Self::Target) -> Self
Construct a thunk with a precomputed value. This means unwrapping/dereferencing is effectively a no-op. Read more