Skip to main content

Memo

Struct Memo 

Source
pub struct Memo<T>
where T: 'static,
{ /* private fields */ }
Expand description

Zero-overhead Copy handle to a lazy, glitch-free memoized reactive computation.

Implementations§

Source§

impl<T> Memo<T>
where T: 'static,

Identity accessors for Memo<T>.

Source

pub fn id(&self) -> MemoId

Returns the underlying MemoId.

§Arguments
  • &Self - Memo handle.
§Returns
  • MemoId - Underlying arena identifier.
Source§

impl<T> Memo<T>
where T: Clone + PartialEq + 'static,

Core reactive memoization operations for Memo<T>.

Source

pub fn new<F>(compute: F) -> Self
where F: FnMut() -> T + 'static,

Creates a new memoized derived computation with value-equality short-circuiting.

§Arguments
  • F - Computation closure evaluated lazily when upstream dependencies change.
§Returns
  • Self - Copyable handle to the memo.
Source

pub fn try_get(&self) -> Option<T>

Evaluates the memo if stale, tracks it in the current observer, and returns a cloned value.

§Arguments
  • &Self - Memo handle to read.
§Returns
  • Option<T> - Current computed value if alive.
Source

pub fn get(&self) -> T
where T: Default,

Evaluates the memo if stale and returns the value or T::default() if disposed.

§Arguments
  • &Self - Memo handle to read.
§Returns
  • T - Computed value or default fallback.
Source

pub fn dispose(&self)

Disposes this memo and detaches its dependency links.

§Arguments
  • &Self - Memo handle to dispose.

Trait Implementations§

Source§

impl<T> Clone for Memo<T>
where T: 'static,

Manual Clone implementation so Memo<T> is always Copy.

Source§

fn clone(&self) -> Self

Copies the lightweight 8-byte memo handle.

§Arguments
  • &Self - Memo handle to copy.
§Returns
  • Self - Identical memo handle.
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<T> Copy for Memo<T>
where T: 'static,

Marker Copy implementation for Memo<T>.

Source§

impl<T> Debug for Memo<T>
where T: 'static + Debug,

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<T> Eq for Memo<T>
where T: 'static,

Reflexive equality for Memo<T>.

Source§

impl<T> PartialEq for Memo<T>
where T: 'static,

Equality comparison by underlying MemoId.

Source§

fn eq(&self, other: &Self) -> bool

Compares two memo handles by arena identifier.

§Arguments
  • &Self - Left-hand memo handle.
  • &Self - Right-hand memo handle.
§Returns
  • bool - True if both handles reference the same memo slot and generation.
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more

Auto Trait Implementations§

§

impl<T> Forget for Memo<T>

§

impl<T> Freeze for Memo<T>
where PhantomData<fn() -> T>: Freeze,

§

impl<T> Move for Memo<T>

§

impl<T> RefUnwindSafe for Memo<T>

§

impl<T> Send for Memo<T>

§

impl<T> Sync for Memo<T>

§

impl<T> Unpin for Memo<T>

§

impl<T> UnsafeUnpin for Memo<T>
where PhantomData<fn() -> T>: UnsafeUnpin,

§

impl<T> UnwindSafe for Memo<T>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

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

fn clone_into(&self, target: &mut T)

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

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.