Enum cosmic_undo_2::CommandItem
source · pub enum CommandItem<T> {
Command(T),
Undo(usize),
}
Expand description
The items stored in Commands.
The list of CommandItem
is accessible by dereferencing
the command list.
NB: The value inside the Undo variant is the number of time the undo command is repeated minus 1.
Example
use undo_2::{Commands,CommandItem};
let mut commands = Commands::new();
#[derive(Debug,PartialEq)]
struct A;
commands.push(A);
commands.undo();
assert_eq!(*commands, [CommandItem::Command(A),CommandItem::Undo(0)]);
use CommandItem::Undo;
assert_eq!(*commands, [A.into(), Undo(0)]);
commands.push(A);
commands.undo();
commands.undo();
assert_eq!(*commands, [A.into(), Undo(0),A.into(),Undo(1)]);
Variants§
Trait Implementations§
source§impl<T: Clone> Clone for CommandItem<T>
impl<T: Clone> Clone for CommandItem<T>
source§fn clone(&self) -> CommandItem<T>
fn clone(&self) -> CommandItem<T>
Returns a copy of the value. Read more
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moresource§impl<T: Debug> Debug for CommandItem<T>
impl<T: Debug> Debug for CommandItem<T>
source§impl<'de, T> Deserialize<'de> for CommandItem<T>where
T: Deserialize<'de>,
impl<'de, T> Deserialize<'de> for CommandItem<T>where T: Deserialize<'de>,
source§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
source§impl<T> From<T> for CommandItem<T>
impl<T> From<T> for CommandItem<T>
source§impl<T: Hash> Hash for CommandItem<T>
impl<T: Hash> Hash for CommandItem<T>
source§impl<T: PartialEq> PartialEq for CommandItem<T>
impl<T: PartialEq> PartialEq for CommandItem<T>
source§fn eq(&self, other: &CommandItem<T>) -> bool
fn eq(&self, other: &CommandItem<T>) -> bool
This method tests for
self
and other
values to be equal, and is used
by ==
.source§impl<T> Serialize for CommandItem<T>where
T: Serialize,
impl<T> Serialize for CommandItem<T>where T: Serialize,
impl<T: Copy> Copy for CommandItem<T>
impl<T: Eq> Eq for CommandItem<T>
impl<T> StructuralEq for CommandItem<T>
impl<T> StructuralPartialEq for CommandItem<T>
Auto Trait Implementations§
impl<T> RefUnwindSafe for CommandItem<T>where T: RefUnwindSafe,
impl<T> Send for CommandItem<T>where T: Send,
impl<T> Sync for CommandItem<T>where T: Sync,
impl<T> Unpin for CommandItem<T>where T: Unpin,
impl<T> UnwindSafe for CommandItem<T>where T: UnwindSafe,
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more