pub struct ComputableIdentity<T> { /* private fields */ }Expand description
A trivial Computable that immediately returns a pre-computed value.
This is useful for wrapping an already-computed value in the Computable interface,
allowing it to be used in contexts that expect a computation.
After the value is returned once, subsequent calls to Computable::try_compute will
return Incomplete::Exhausted.
§Example
use computation_process::{ComputableIdentity, Computable};
let mut identity: ComputableIdentity<i32> = 42.into();
assert_eq!(identity.try_compute(), Ok(42));Trait Implementations§
Source§impl<T: Clone> Clone for ComputableIdentity<T>
impl<T: Clone> Clone for ComputableIdentity<T>
Source§fn clone(&self) -> ComputableIdentity<T>
fn clone(&self) -> ComputableIdentity<T>
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl<T> Computable<T> for ComputableIdentity<T>
impl<T> Computable<T> for ComputableIdentity<T>
Source§fn try_compute(&mut self) -> Completable<T>
fn try_compute(&mut self) -> Completable<T>
Try to advance this computation, returning a value once the computation is done.
Source§fn compute_completable(&mut self) -> Completable<T>
fn compute_completable(&mut self) -> Completable<T>
Advance this computation until it either completes, is canceled, or becomes exhausted,
skipping over all suspended states. Read more
Source§fn compute(&mut self) -> Cancellable<T>
fn compute(&mut self) -> Cancellable<T>
Advance this computation until completion, skipping over all suspended states. Read more
Source§fn dyn_computable(self) -> DynComputable<T>where
Self: Sized + 'static,
fn dyn_computable(self) -> DynComputable<T>where
Self: Sized + 'static,
Utility method to convert this
Computable to a dynamic type.Source§impl<T: Debug> Debug for ComputableIdentity<T>
impl<T: Debug> Debug for ComputableIdentity<T>
Source§impl<T> From<T> for ComputableIdentity<T>
impl<T> From<T> for ComputableIdentity<T>
Source§impl<T: PartialEq> PartialEq for ComputableIdentity<T>
impl<T: PartialEq> PartialEq for ComputableIdentity<T>
impl<T: Eq> Eq for ComputableIdentity<T>
impl<T> StructuralPartialEq for ComputableIdentity<T>
Auto Trait Implementations§
impl<T> Freeze for ComputableIdentity<T>where
T: Freeze,
impl<T> RefUnwindSafe for ComputableIdentity<T>where
T: RefUnwindSafe,
impl<T> Send for ComputableIdentity<T>where
T: Send,
impl<T> Sync for ComputableIdentity<T>where
T: Sync,
impl<T> Unpin for ComputableIdentity<T>where
T: Unpin,
impl<T> UnwindSafe for ComputableIdentity<T>where
T: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more