[][src]Struct snec::ModificationScope

pub struct ModificationScope<'a, 'b, E, R> where
    E: Entry,
    R: Receiver<E>, 
{ /* fields omitted */ }

A drop guard for modifying data bahind a Handle using a mutable reference instead of moving in a new value.

Since Storage should notify a receiver whenever data inside of it is modified, it cannot simply hand out mutable references to the value, because that'd allow outside code to implicitly perform a silent storage modification. While ways to do so are also provided, it's heavily discouraged and reserved for special cases.

The solution to the problem is this struct: ModificationScope. It's a drop guard which is created by providing a receiver to the storage. While it has little to no differences to a mutable reference to the data inside in terms of functionality, it notifies the receiver when dropped, ensuring that it will get modified even if a panic or any other kind of early return happens.

Trait Implementations

impl<'a, 'b, E, R> AsMut<Handle<'a, E, R>> for ModificationScope<'a, 'b, E, R> where
    E: Entry,
    R: Receiver<E>, 
[src]

impl<'a, 'b, E, R> AsRef<Handle<'a, E, R>> for ModificationScope<'a, 'b, E, R> where
    E: Entry,
    R: Receiver<E>, 
[src]

impl<'a, 'b, E, R> Debug for ModificationScope<'a, 'b, E, R> where
    E: Entry,
    E::Data: Debug,
    R: Receiver<E> + Debug
[src]

impl<'a, 'b, E, R> Deref for ModificationScope<'a, 'b, E, R> where
    E: Entry,
    R: Receiver<E>, 
[src]

type Target = E::Data

The resulting type after dereferencing.

impl<'a, 'b, E, R> DerefMut for ModificationScope<'a, 'b, E, R> where
    E: Entry,
    R: Receiver<E>, 
[src]

impl<'a, 'b, E, R> Drop for ModificationScope<'a, 'b, E, R> where
    E: Entry,
    R: Receiver<E>, 
[src]

Auto Trait Implementations

impl<'a, 'b, E, R> RefUnwindSafe for ModificationScope<'a, 'b, E, R> where
    E: RefUnwindSafe,
    R: RefUnwindSafe,
    <E as Entry>::Data: RefUnwindSafe

impl<'a, 'b, E, R> Send for ModificationScope<'a, 'b, E, R> where
    E: Send,
    R: Send,
    <E as Entry>::Data: Send

impl<'a, 'b, E, R> Sync for ModificationScope<'a, 'b, E, R> where
    E: Sync,
    R: Sync,
    <E as Entry>::Data: Sync

impl<'a, 'b, E, R> Unpin for ModificationScope<'a, 'b, E, R> where
    'a: 'b, 

impl<'a, 'b, E, R> !UnwindSafe for ModificationScope<'a, 'b, E, R>

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.