Struct thunk::unsync::RcThunk
[−]
[src]
pub struct RcThunk<'a, T: 'a>(_);
An Rc
-wrapped Thunk
which implements LazyRef
.
Methods
impl<'a, T: 'a> RcThunk<'a, T>
[src]
fn try_unwrap(this: RcThunk<'a, T>) -> Result<T, RcThunk<'a, T>>
If the RcThunk
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 RcThunk
.
fn get_mut<'b>(this: &'b mut RcThunk<'a, T>) -> Option<&'b mut T>
If the RcThunk
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 RcThunk<'a, T>) -> &'b mut T where
T: Clone,
T: Clone,
If the RcThunk
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 RcThunk
passed in will be updated to reference the
newly cloned value.
Trait Implementations
impl<'a, T: 'a> Clone for RcThunk<'a, T>
[src]
fn clone(&self) -> RcThunk<'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 RcThunk<'a, T>
[src]
fn as_ref(&self) -> &T
Performs the conversion.
impl<'a, T: 'a> Deref for RcThunk<'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 RcThunk<'a, T>
[src]
impl<'a, T: 'a> LazyRef<'a> for RcThunk<'a, T>
[src]
fn defer<F: FnOnce() -> T + 'a>(f: F) -> RcThunk<'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