Struct undo::timeline::Timeline [−][src]
pub struct Timeline<A, F, const LIMIT: usize> { /* fields omitted */ }
Expand description
A timeline of actions.
A timeline works mostly like a record but stores a fixed number of actions on the stack.
Can be used without the alloc
feature.
Examples
let mut target = String::new(); let mut timeline = Timeline::<_, _, 32>::new(); timeline.apply(&mut target, Add('a'))?; timeline.apply(&mut target, Add('b'))?; timeline.apply(&mut target, Add('c'))?; assert_eq!(target, "abc"); timeline.undo(&mut target).unwrap()?; timeline.undo(&mut target).unwrap()?; timeline.undo(&mut target).unwrap()?; assert_eq!(target, ""); timeline.redo(&mut target).unwrap()?; timeline.redo(&mut target).unwrap()?; timeline.redo(&mut target).unwrap()?; assert_eq!(target, "abc");
Implementations
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.
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
impl<'de, A, F, const LIMIT: usize> Deserialize<'de> for Timeline<A, F, LIMIT> where
A: Deserialize<'de>,
impl<'de, A, F, const LIMIT: usize> Deserialize<'de> for Timeline<A, F, LIMIT> where
A: 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<A, F, const LIMIT: usize> RefUnwindSafe for Timeline<A, F, LIMIT> where
A: RefUnwindSafe,
F: RefUnwindSafe,
impl<A, F, const LIMIT: usize> UnwindSafe for Timeline<A, F, LIMIT> where
A: UnwindSafe,
F: UnwindSafe,
Blanket Implementations
Mutably borrows from an owned value. Read more