pub struct Values(/* private fields */);Expand description
Cache that can store any value.
It uses a key type to identify the value inserted to the cache. The key type
needs to implement ValueKey.
Implementations§
Source§impl Values
impl Values
Sourcepub fn set<K>(&mut self, value: K::Type)where
K: ValueKey,
pub fn set<K>(&mut self, value: K::Type)where
K: ValueKey,
Set a value for the specified key K.
Sourcepub fn get<K>(&self) -> K::Type
pub fn get<K>(&self) -> K::Type
Get the value that was stored for the specified key K.
Panics if the key was not set before.
Sourcepub fn get_ref<K>(&self) -> &K::Typewhere
K: ValueKey,
pub fn get_ref<K>(&self) -> &K::Typewhere
K: ValueKey,
Get a reference to the value that was stored for the specified key K.
Panics if the key was not set before.
Sourcepub fn get_mut<K>(&mut self) -> &mut K::Typewhere
K: ValueKey,
pub fn get_mut<K>(&mut self) -> &mut K::Typewhere
K: ValueKey,
Get a mutable reference to the value that was stored for the specified key K.
Panics if the key was not set before.
Sourcepub fn get_or_create<K>(&mut self) -> &mut K::Type
pub fn get_or_create<K>(&mut self) -> &mut K::Type
Get a mutable reference to the value that was stored for the specified key K.
If no value is available a new one is created.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Values
impl !RefUnwindSafe for Values
impl !Send for Values
impl !Sync for Values
impl Unpin for Values
impl !UnwindSafe for Values
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