CtxMapView

Struct CtxMapView 

Source
pub struct CtxMapView<'a, S: Schema>(/* private fields */);
Expand description

Mutable reference to CtxMap where the value has changed.

Use CtxMapViwe instead of &mut CtxMap because &mut CtxMap, whose value has been changed, will be broken if std::mem::swap is used.

Implementations§

Source§

impl<'a, S: Schema> CtxMapView<'a, S>

Source

pub fn with<T: ?Sized + 'static, U>( &mut self, key: &'static Key<S, T>, value: &T, f: impl FnOnce(&mut CtxMapView<'_, S>) -> U, ) -> U

Sets a value to CtxMap only while f is being called.

See CtxMap::with for more details.

Source

pub fn with_mut<T: ?Sized + 'static, U, const MUT: bool>( &mut self, key: &'static Key<S, T, MUT>, value: &mut T, f: impl FnOnce(&mut CtxMapView<'_, S>) -> U, ) -> U

Sets a mutable value to CtxMap only while f is being called.

See CtxMap::with_mut for more details.

Source

pub fn view(&mut self) -> CtxMapView<'_, S>

Return CtxMapView with modified lifetime.

Source

pub fn get<T: ?Sized, const MUT: bool>( &self, key: &'static Key<S, T, MUT>, ) -> Option<&T>

Returns a reference to the value corresponding to the key.

See CtxMap::get for more details.

Source

pub fn get_mut<T: ?Sized>( &mut self, key: &'static KeyMut<S, T>, ) -> Option<&mut T>

Returns a mutable reference to the value corresponding to the key.

See CtxMap::get_mut for more details.

Trait Implementations§

Source§

impl<'a, S, T, const MUT: bool> Index<&'static Key<S, T, MUT>> for CtxMapView<'a, S>
where S: Schema, T: ?Sized + 'static,

Source§

type Output = T

The returned type after indexing.
Source§

fn index(&self, index: &'static Key<S, T, MUT>) -> &Self::Output

Performs the indexing (container[index]) operation. Read more
Source§

impl<'a, S, T> IndexMut<&'static Key<S, T, true>> for CtxMapView<'a, S>
where S: Schema, T: ?Sized + 'static,

Source§

fn index_mut(&mut self, index: &'static KeyMut<S, T>) -> &mut Self::Output

Performs the mutable indexing (container[index]) operation. Read more

Auto Trait Implementations§

§

impl<'a, S> Freeze for CtxMapView<'a, S>

§

impl<'a, S> !RefUnwindSafe for CtxMapView<'a, S>

§

impl<'a, S> !Send for CtxMapView<'a, S>

§

impl<'a, S> !Sync for CtxMapView<'a, S>

§

impl<'a, S> Unpin for CtxMapView<'a, S>

§

impl<'a, S> !UnwindSafe for CtxMapView<'a, S>

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.