command : ajout fonction add
This commit is contained in:
parent
d7f2de803d
commit
8d039e3de3
1 changed files with 9 additions and 1 deletions
|
@ -24,7 +24,7 @@ pub trait Command {
|
|||
|
||||
pub struct CommandSequence {
|
||||
command: Box<dyn Command>,
|
||||
next_command: Option<Box<dyn Command>>,
|
||||
next_command: Option<Box<CommandSequence>>,
|
||||
}
|
||||
|
||||
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 {
|
||||
|
|
Loading…
Reference in a new issue