Struct redo::history::History [−][src]
Expand description
A history of commands.
Unlike Record which maintains a linear undo history, History maintains an undo tree containing every edit made to the target.
Examples
let mut history = History::default();
history.apply(Add('a'))?;
history.apply(Add('b'))?;
history.apply(Add('c'))?;
let abc = history.branch();
history.go_to(abc, 1).unwrap()?;
history.apply(Add('f'))?;
history.apply(Add('g'))?;
assert_eq!(history.target(), "afg");
history.go_to(abc, 3).unwrap()?;
assert_eq!(history.target(), "abc");
Implementations
Reserves capacity for at least additional
more commands.
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.
Returns a structure for configurable formatting of the history.
Returns a mutable reference to the target
.
This method should only be used when doing changes that should not be able to be undone.
Consumes the history, returning the target
.
Marks the target as currently being in a saved or unsaved state.
Trait Implementations
impl<'de, C: Command, F> Deserialize<'de> for History<C, F> where
C: Command + Deserialize<'de>,
C::Target: Deserialize<'de>,
impl<'de, C: Command, F> Deserialize<'de> for History<C, F> where
C: Command + Deserialize<'de>,
C::Target: Deserialize<'de>,
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<C, F> RefUnwindSafe for History<C, F> where
C: RefUnwindSafe,
F: RefUnwindSafe,
<C as Command>::Target: RefUnwindSafe,
impl<C, F> UnwindSafe for History<C, F> where
C: UnwindSafe + RefUnwindSafe,
F: UnwindSafe,
<C as Command>::Target: UnwindSafe,
Blanket Implementations
Mutably borrows from an owned value. Read more