Struct StoreProxy

Source
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>

Source

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.

Source

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.

Source

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.

Source

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.

Source

pub fn with_value<V: Any + 'static, T, F>( &mut self, token: &Token<V>, f: F, ) -> T
where F: FnOnce(&mut StoreProxy<'_>, &mut V) -> 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.

Trait Implementations§

Source§

impl<'a> From<&'a mut Store> for StoreProxy<'a>

Source§

fn from(store: &'a mut Store) -> StoreProxy<'a>

Converts to this type from the input type.
Source§

impl<'a, 'b> From<&'a mut StoreProxy<'b>> for StoreProxy<'a>
where 'b: 'a,

Source§

fn from(proxy: &'a mut StoreProxy<'b>) -> StoreProxy<'a>

Converts to this type from the input type.

Auto Trait Implementations§

§

impl<'store> Freeze for StoreProxy<'store>

§

impl<'store> !RefUnwindSafe for StoreProxy<'store>

§

impl<'store> !Send for StoreProxy<'store>

§

impl<'store> !Sync for StoreProxy<'store>

§

impl<'store> Unpin for StoreProxy<'store>

§

impl<'store> !UnwindSafe for StoreProxy<'store>

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.