pub struct Inverse { /* private fields */ }Expand description
The recorded undo of a run of writes. See the module docs.
Implementations§
Source§impl Inverse
impl Inverse
Sourcepub fn record<T>(
model: &mut Model,
change: impl FnOnce(&mut Model) -> T,
) -> (T, Inverse)
pub fn record<T>( model: &mut Model, change: impl FnOnce(&mut Model) -> T, ) -> (T, Inverse)
Run change on model and return its result with the inverse of
every write it made.
If change panics the recording is closed before the panic resumes.
Sourcepub fn summary(&self, model: &Model) -> Restored
pub fn summary(&self, model: &Model) -> Restored
The net effect of applying this inverse to model, computed without
applying it.
Sourcepub fn apply(
self,
model: &mut Model,
) -> Result<(Restored, Inverse), InverseError>
pub fn apply( self, model: &mut Model, ) -> Result<(Restored, Inverse), InverseError>
Restore the model to the state before the recorded writes.
Returns what changed and the inverse of this application, which redoes the writes. A model that moved on since recording is refused and left untouched.
Trait Implementations§
impl StructuralPartialEq for Inverse
Auto Trait Implementations§
impl Freeze for Inverse
impl RefUnwindSafe for Inverse
impl Send for Inverse
impl Sync for Inverse
impl Unpin for Inverse
impl UnsafeUnpin for Inverse
impl UnwindSafe for Inverse
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more