Struct RefCache

Source
pub struct RefCache<'c, C: SparseContainer> { /* private fields */ }

Implementations§

Source§

impl<'c, C: SparseContainer> RefCache<'c, C>

Source

pub fn new( cache: &'c mut C, f: &'c (dyn Fn(&mut Self, &C::Input) -> C::Output + Send), ) -> Self

Trait Implementations§

Source§

impl<'c, C> FnCache<<C as SparseContainer>::Input, <C as SparseContainer>::Output> for RefCache<'c, C>
where C: SparseContainer,

Source§

fn get(&mut self, input: C::Input) -> &C::Output

Retrieve a value stored in the cache. If the value does not yet exist in the cache, the function is called, and the result is added to the cache before returning it.
Source§

impl<'c, C> FnCacheMany<<C as SparseContainer>::Input, <C as SparseContainer>::Output> for RefCache<'c, C>
where C: SparseContainer, C::Input: Clone,

Source§

fn get_many<const N: usize>(&mut self, inputs: [C::Input; N]) -> [&C::Output; N]

Retrieve multiple values stored in the cache. If any of the values do not yet exist, the function is called, and the result is added to the cache before returning them. Read more

Auto Trait Implementations§

§

impl<'c, C> Freeze for RefCache<'c, C>

§

impl<'c, C> !RefUnwindSafe for RefCache<'c, C>

§

impl<'c, C> !Send for RefCache<'c, C>

§

impl<'c, C> !Sync for RefCache<'c, C>

§

impl<'c, C> Unpin for RefCache<'c, C>

§

impl<'c, C> !UnwindSafe for RefCache<'c, C>

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> 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, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.