pub struct ContentMemo<K, V>{ /* private fields */ }Expand description
A single-threaded content-keyed memo. K is the content address; the
value Rc<V> is a pure function of K (see the module invariant).
A hit is a cheap Rc::clone.
Implementations§
Source§impl<K, V> ContentMemo<K, V>
impl<K, V> ContentMemo<K, V>
Sourcepub fn new() -> ContentMemo<K, V>
pub fn new() -> ContentMemo<K, V>
A fresh empty memo.
Sourcepub fn get_or_compute(&self, key: K, compute: impl FnOnce() -> V) -> Rc<V>
pub fn get_or_compute(&self, key: K, compute: impl FnOnce() -> V) -> Rc<V>
Return the memoized value for key, computing + storing it via
compute on a miss. A hit is a cheap Rc::clone and is byte-identical
to a recompute by the module’s purity invariant (the caller’s
responsibility — compute must be a pure function of key).
Source§impl<T, V> ContentMemo<ContentKey<T>, V>where
T: Hash,
impl<T, V> ContentMemo<ContentKey<T>, V>where
T: Hash,
Sourcepub fn get_or_compute_keyed(
&self,
input: &T,
compute: impl FnOnce(&T) -> V,
) -> Rc<V>
pub fn get_or_compute_keyed( &self, input: &T, compute: impl FnOnce(&T) -> V, ) -> Rc<V>
The keyed memo API — the M3 seal for the key↔content decoupling axis.
Derives the ContentKey from input internally (so the key is
provably the content address of input, not some ambient value the
caller passed alongside it) and hands the same &input to
compute. A caller therefore cannot memoize under a key decoupled
from the computed input — the decoupling has no constructor.
A hit is a cheap Rc::clone and is byte-identical to a recompute by
the module’s purity invariant — compute must still be a pure
function of its &T argument (the C1-ceiling purity axis this seal does
NOT close; see ContentKey).
Trait Implementations§
Source§impl<K, V> Debug for ContentMemo<K, V>
impl<K, V> Debug for ContentMemo<K, V>
Auto Trait Implementations§
impl<K, V> !Freeze for ContentMemo<K, V>
impl<K, V> !RefUnwindSafe for ContentMemo<K, V>
impl<K, V> !Send for ContentMemo<K, V>
impl<K, V> !Sync for ContentMemo<K, V>
impl<K, V> Unpin for ContentMemo<K, V>where
K: Unpin,
impl<K, V> UnsafeUnpin for ContentMemo<K, V>
impl<K, V> UnwindSafe for ContentMemo<K, V>where
K: UnwindSafe,
V: RefUnwindSafe,
Blanket Implementations§
Source§impl<T> ArchivePointee for T
impl<T> ArchivePointee for T
Source§type ArchivedMetadata = ()
type ArchivedMetadata = ()
Source§fn pointer_metadata(
_: &<T as ArchivePointee>::ArchivedMetadata,
) -> <T as Pointee>::Metadata
fn pointer_metadata( _: &<T as ArchivePointee>::ArchivedMetadata, ) -> <T as Pointee>::Metadata
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
Source§impl<T> LayoutRaw for T
impl<T> LayoutRaw for T
Source§fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>
fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>
Source§impl<T, N1, N2> Niching<NichedOption<T, N1>> for N2
impl<T, N1, N2> Niching<NichedOption<T, N1>> for N2
Source§unsafe fn is_niched(niched: *const NichedOption<T, N1>) -> bool
unsafe fn is_niched(niched: *const NichedOption<T, N1>) -> bool
Source§fn resolve_niched(out: Place<NichedOption<T, N1>>)
fn resolve_niched(out: Place<NichedOption<T, N1>>)
out indicating that a T is niched.