Struct undo::history::History [−][src]
Expand description
A history of actions.
Unlike Record which maintains a linear undo history, History maintains an undo tree containing every edit made to the target.
Examples
let mut target = String::new();
let mut history = History::new();
history.apply(&mut target, Add('a')).unwrap();
history.apply(&mut target, Add('b')).unwrap();
history.apply(&mut target, Add('c')).unwrap();
let abc = history.branch();
history.go_to(&mut target, abc, 1).unwrap().unwrap();
history.apply(&mut target, Add('f')).unwrap();
history.apply(&mut target, Add('g')).unwrap();
assert_eq!(target, "afg");
history.go_to(&mut target, abc, 3).unwrap().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 history 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.
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 History<A, F> where
A: RefUnwindSafe,
F: RefUnwindSafe,
impl<A, F> UnwindSafe for History<A, F> where
A: UnwindSafe + RefUnwindSafe,
F: UnwindSafe,
Blanket Implementations
Mutably borrows from an owned value. Read more