Struct undo::record::Record [−][src]
Expand description
A record of actions.
The record can roll the targets state backwards and forwards by using
the undo and redo methods. In addition, the record can notify the user
about changes to the stack or the target through signal.
The user can give the record a function that is called each time the state
changes by using the builder
.
Examples
let mut target = String::new(); let mut record = Record::new(); record.apply(&mut target, Add('a'))?; record.apply(&mut target, Add('b'))?; record.apply(&mut target, Add('c'))?; assert_eq!(target, "abc"); record.undo(&mut target).unwrap()?; record.undo(&mut target).unwrap()?; record.undo(&mut target).unwrap()?; assert_eq!(target, ""); record.redo(&mut target).unwrap()?; record.redo(&mut target).unwrap()?; record.redo(&mut target).unwrap()?; assert_eq!(target, "abc");
Implementations
Reserves capacity for at least additional
more actions.
Panics
Panics if the new capacity overflows usize.
Shrinks the capacity of the record as much as possible.
Sets how the signal should be handled when the state changes.
The previous slot is returned if it exists.
Removes and returns the slot if it exists.
Returns a checkpoint.
Marks the target as currently being in a saved or unsaved state.
Revert the changes done to the target since the saved state.
Trait Implementations
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error> where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error> where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Auto Trait Implementations
impl<A, F> RefUnwindSafe for Record<A, F> where
A: RefUnwindSafe,
F: RefUnwindSafe,
impl<A, F> UnwindSafe for Record<A, F> where
A: UnwindSafe,
F: UnwindSafe,
Blanket Implementations
Mutably borrows from an owned value. Read more