command : passage de la reference à self
en mut
dans le trait
Command
This commit is contained in:
parent
b06b0f1c15
commit
5f59139c3e
1 changed files with 10 additions and 4 deletions
|
@ -19,7 +19,7 @@ impl ExitCode {
|
|||
}
|
||||
|
||||
pub trait Command {
|
||||
fn spawn(&self) -> ExitCode;
|
||||
fn spawn(&mut self) -> ExitCode;
|
||||
}
|
||||
|
||||
pub struct CommandSequence {
|
||||
|
@ -46,11 +46,11 @@ impl CommandSequence {
|
|||
}
|
||||
|
||||
impl Command for CommandSequence {
|
||||
fn spawn(&self) -> ExitCode {
|
||||
fn spawn(&mut self) -> ExitCode {
|
||||
let mut exit_code = self.command.spawn();
|
||||
|
||||
if self.next_command.is_some() {
|
||||
exit_code = self.next_command.as_ref().unwrap().spawn();
|
||||
exit_code = self.next_command.as_mut().unwrap().spawn();
|
||||
}
|
||||
|
||||
exit_code
|
||||
|
@ -75,7 +75,13 @@ impl Command for UnixProgram {
|
|||
let mut command = std::process::Command::new(&program);
|
||||
command.args(argv);
|
||||
|
||||
let handle = command.spawn();
|
||||
Self { command }
|
||||
}
|
||||
}
|
||||
|
||||
impl Command for UnixProgram {
|
||||
fn spawn(&mut self) -> ExitCode {
|
||||
let handle = self.command.spawn();
|
||||
|
||||
if handle.is_ok() {
|
||||
let exit_code = handle
|
||||
|
|
Loading…
Reference in a new issue