[][src]Struct undo::Chain

pub struct Chain<R> { /* fields omitted */ }

A chain of merged commands.

Commands in a chain are all executed in the order they was merged in.

Examples

let mut record = Record::default();
let chain = Chain::with_capacity(2)
    .join(Add('a'))
    .join(Add('b'));
record.apply(chain)?;
assert_eq!(record.as_receiver(), "ab");
record.undo().unwrap()?;
assert_eq!(record.as_receiver(), "");
record.redo().unwrap()?;
assert_eq!(record.as_receiver(), "ab");

Methods

impl<R> Chain<R>[src]

pub fn new() -> Chain<R>[src]

Returns an empty command.

pub fn with_text(text: impl Into<String>) -> Chain<R>[src]

Returns an empty command with the specified display text.

pub fn with_capacity(capacity: usize) -> Chain<R>[src]

Returns an empty command with the specified capacity.

pub fn reserve(&mut self, additional: usize)[src]

Reserves capacity for at least additional more commands in the chain.

Panics

Panics if the new capacity overflows usize.

pub fn capacity(&self) -> usize[src]

Returns the capacity of the chain.

pub fn shrink_to_fit(&mut self)[src]

Shrinks the capacity of the chain as much as possible.

pub fn len(&self) -> usize[src]

Returns the amount of commands in the chain.

pub fn is_empty(&self) -> bool[src]

Returns true if no commands have been merged.

pub fn push(&mut self, command: impl Command<R> + 'static)[src]

Merges the command with the chain.

pub fn join(self, command: impl Command<R> + 'static) -> Chain<R>[src]

Merges the command with the chain and returns the chain.

pub fn set_merge(&mut self, merge: Merge)[src]

Sets the merge behavior of the chain.

By default the merge behavior of the first command in the chain is used, and it merges if the chain is empty.

pub fn set_text(&mut self, text: impl Into<String>)[src]

Sets the display text for the chain.

By default the display text will be the display text for every command in the chain.

Trait Implementations

impl<R> Command<R> for Chain<R>[src]

impl<R, C: Command<R> + 'static> Extend<C> for Chain<R>[src]

impl<R> Default for Chain<R>[src]

impl<R> IntoIterator for Chain<R>[src]

type Item = Box<dyn Command<R>>

The type of the elements being iterated over.

type IntoIter = IntoIter<Self::Item>

Which kind of iterator are we turning this into?

impl<R> Debug for Chain<R>[src]

impl<R> Display for Chain<R>[src]

impl<R, C: Command<R> + 'static> FromIterator<C> for Chain<R>[src]

Auto Trait Implementations

impl<R> !Send for Chain<R>

impl<R> !Sync for Chain<R>

impl<R> Unpin for Chain<R>

impl<R> !UnwindSafe for Chain<R>

impl<R> !RefUnwindSafe for Chain<R>

Blanket Implementations

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<I> IntoIterator for I where
    I: Iterator
[src]

type Item = <I as Iterator>::Item

The type of the elements being iterated over.

type IntoIter = I

Which kind of iterator are we turning this into?

impl<T> ToString for T where
    T: Display + ?Sized
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> Any for T where
    T: 'static + ?Sized
[src]