Struct rustc_utils::cache::CopyCache
source · pub struct CopyCache<In, Out>(/* private fields */);
Expand description
Cache for copyable types.
Implementations§
source§impl<In, Out> CopyCache<In, Out>
impl<In, Out> CopyCache<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(
&self,
key: In,
compute: impl FnOnce(In) -> Out
) -> Option<Out>
pub fn get_maybe_recursive( &self, key: In, compute: impl FnOnce(In) -> Out ) -> Option<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 CopyCache<In, Out>
impl<In, Out> Send for CopyCache<In, Out>
impl<In, Out> !Sync for CopyCache<In, Out>
impl<In, Out> Unpin for CopyCache<In, Out>
impl<In, Out> UnwindSafe for CopyCache<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