diff --git a/src/command.rs b/src/command.rs index bced27d..1634de3 100644 --- a/src/command.rs +++ b/src/command.rs @@ -24,7 +24,7 @@ pub trait Command { pub struct CommandSequence { command: Box, - next_command: Option>, + next_command: Option>, } impl CommandSequence { @@ -34,6 +34,14 @@ impl CommandSequence { next_command: None, } } + + pub fn add(&mut self, command: impl Command + 'static) { + if self.next_command.is_none() { + self.next_command = Some(Box::new(CommandSequence::new(command))); + } else { + self.next_command.as_mut().unwrap().add(command); + } + } } impl Command for CommandSequence {