Struct clone_replace::MutateGuard
source · [−]pub struct MutateGuard<T> { /* private fields */ }
Expand description
A handle to a writeable version of the data.
This structure is created by the mutate method on CloneReplace. The data held by the guard can be accessed via its Deref and DerefMut implementations.
When the guard is dropped, the contents will be written back to become the new reference version of the data. Any intermediate writes that occurred between the mutate guard being constructed and the writeback will be discarded.
Implementations
sourceimpl<T> MutateGuard<T>
impl<T> MutateGuard<T>
sourcepub fn discard(self)
pub fn discard(self)
Discard the changes made in this mutation session.
The changed data will not be written back to its origin. If you do not call discard, the changes will always be committed when the guard goes out of scope.
Example:
use clone_replace::CloneReplace;
let c = CloneReplace::new(1);
let mut v = c.mutate();
*v = 2;
v.discard();
assert_eq!(*c.access(), 1);
Trait Implementations
sourceimpl<T> Deref for MutateGuard<T>
impl<T> Deref for MutateGuard<T>
sourceimpl<T> DerefMut for MutateGuard<T>
impl<T> DerefMut for MutateGuard<T>
sourceimpl<T: Display> Display for MutateGuard<T>
impl<T: Display> Display for MutateGuard<T>
Auto Trait Implementations
impl<T> RefUnwindSafe for MutateGuard<T> where
T: RefUnwindSafe,
impl<T> Send for MutateGuard<T> where
T: Send + Sync,
impl<T> Sync for MutateGuard<T> where
T: Send + Sync,
impl<T> Unpin for MutateGuard<T> where
T: Unpin,
impl<T> UnwindSafe for MutateGuard<T> where
T: UnwindSafe + RefUnwindSafe,
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T, A> DynAccess<T> for A where
A: Access<T>,
<A as Access<T>>::Guard: 'static,
impl<T, A> DynAccess<T> for A where
A: Access<T>,
<A as Access<T>>::Guard: 'static,
sourcefn load(&self) -> DynGuard<T>
fn load(&self) -> DynGuard<T>
The equivalent of Access::load
.