[−][src]Struct undo::Chain
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]
fn apply(&mut self, receiver: &mut R) -> Result
[src]
fn undo(&mut self, receiver: &mut R) -> Result
[src]
fn redo(&mut self, receiver: &mut R) -> Result
[src]
fn merge(&self) -> Merge
[src]
fn is_dead(&self) -> bool
[src]
impl<R, C: Command<R> + 'static> Extend<C> for Chain<R>
[src]
fn extend<T: IntoIterator<Item = C>>(&mut self, iter: T)
[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?
fn into_iter(self) -> Self::IntoIter
[src]
impl<R> Default for Chain<R>
[src]
impl<R> Display for Chain<R>
[src]
impl<R> Debug for Chain<R>
[src]
impl<R, C: Command<R> + 'static> FromIterator<C> for Chain<R>
[src]
fn from_iter<T: IntoIterator<Item = C>>(commands: T) -> Self
[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, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> From<T> for T
[src]
impl<I> IntoIterator for I where
I: Iterator,
[src]
I: Iterator,
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?
fn into_iter(self) -> I
[src]
impl<T> ToString for T where
T: Display + ?Sized,
[src]
T: Display + ?Sized,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,