Struct rustc_utils::cache::Cache
source · pub struct Cache<In, Out>(/* private fields */);
Expand description
Cache for non-copyable types.
Implementations§
source§impl<In, Out> Cache<In, Out>
impl<In, Out> Cache<In, Out>
sourcepub fn get(&self, key: In, compute: impl FnOnce(In) -> Out) -> &Out
pub fn get(&self, key: In, compute: impl FnOnce(In) -> Out) -> &Out
Returns the cached value for the given key, or runs compute
if
the value is not in cache.
Panics
If this is a recursive invocation for this key.
sourcepub fn get_maybe_recursive<'a>(
&'a self,
key: In,
compute: impl FnOnce(In) -> Out
) -> Option<&'a Out>
pub fn get_maybe_recursive<'a>( &'a self, key: In, compute: impl FnOnce(In) -> Out ) -> Option<&'a Out>
Returns the cached value for the given key, or runs compute
if
the value is not in cache.
Returns None
if this is a recursive invocation of get
for key key
.
Trait Implementations§
Auto Trait Implementations§
impl<In, Out> !RefUnwindSafe for Cache<In, Out>
impl<In, Out> Send for Cache<In, Out>
impl<In, Out> !Sync for Cache<In, Out>
impl<In, Out> Unpin for Cache<In, Out>where
In: Unpin,
impl<In, Out> UnwindSafe for Cache<In, Out>where
In: UnwindSafe,
Out: 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