pub struct StoreProxy<'store> { /* private fields */ }
Expand description
A Proxy representing a Store
with ongoing borrows
This struct represents a handle to a store from which some values are already mutably borrowed, and as such cannot be touched.
See Store::with_value
for detailed explanation of its
use.
Implementations§
Source§impl<'store> StoreProxy<'store>
impl<'store> StoreProxy<'store>
Sourcepub fn insert<V: Any + 'static>(&mut self, value: V) -> Token<V>
pub fn insert<V: Any + 'static>(&mut self, value: V) -> Token<V>
Insert a new value in the proxified store
Returns a clonable token that you can later use to access this value.
Sourcepub fn get<V: Any + 'static>(&self, token: &Token<V>) -> &V
pub fn get<V: Any + 'static>(&self, token: &Token<V>) -> &V
Access value previously inserted in the proxified store
Panics if the provided token corresponds to a value that was removed, or if this value is already borrowed.
Sourcepub fn get_mut<V: Any + 'static>(&mut self, token: &Token<V>) -> &mut V
pub fn get_mut<V: Any + 'static>(&mut self, token: &Token<V>) -> &mut V
Mutably access value previously inserted in the proxified store
Panics if the provided token corresponds to a value that was removed, or if this value is already borrowed.
Sourcepub fn remove<V: Any + 'static>(&mut self, token: Token<V>) -> V
pub fn remove<V: Any + 'static>(&mut self, token: Token<V>) -> V
Remove a value previously inserted in the proxified store
Panics if the provided token corresponds to a value that was already removed, or if this value is already borrowed.
Sourcepub fn with_value<V: Any + 'static, T, F>(
&mut self,
token: &Token<V>,
f: F,
) -> T
pub fn with_value<V: Any + 'static, T, F>( &mut self, token: &Token<V>, f: F, ) -> T
Create a sub-scope with access to a value
Panics if the provided token corresponds to a value that was removed, or if this value is already borrowed.
See Store::with_value
for full documentation.