Skip to content

Commit 250586c

Browse files
committed
Wrap std Output in CommandOutput
1 parent 3fe4d13 commit 250586c

1 file changed

Lines changed: 13 additions & 12 deletions

File tree

‎src/bootstrap/src/utils/exec.rs‎

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -62,43 +62,44 @@ impl<'a> From<&'a mut Command> for BootstrapCommand<'a> {
6262

6363
/// Represents the output of an executed process.
6464
#[allow(unused)]
65-
#[derive(Default)]
66-
pubstructCommandOutput{
67-
status:ExitStatus,
68-
stdout:Vec<u8>,
69-
stderr:Vec<u8>,
70-
}
65+
pubstructCommandOutput(Output);
7166

7267
implCommandOutput{
7368
pubfnis_success(&self) -> bool{
74-
self.status.success()
69+
self.0.status.success()
7570
}
7671

7772
pubfnis_failure(&self) -> bool{
7873
!self.is_success()
7974
}
8075

8176
pubfnstatus(&self) -> ExitStatus{
82-
self.status
77+
self.0.status
8378
}
8479

8580
pubfnstdout(&self) -> String{
86-
String::from_utf8(self.stdout.clone()).expect("Cannot parse process stdout as UTF-8")
81+
String::from_utf8(self.0.stdout.clone()).expect("Cannot parse process stdout as UTF-8")
8782
}
8883

8984
pubfnstderr(&self) -> String{
90-
String::from_utf8(self.stderr.clone()).expect("Cannot parse process stderr as UTF-8")
85+
String::from_utf8(self.0.stderr.clone()).expect("Cannot parse process stderr as UTF-8")
86+
}
87+
}
88+
89+
implDefaultforCommandOutput{
90+
fndefault() -> Self{
91+
Self(Output{status:Default::default(),stdout:vec![],stderr:vec![]})
9192
}
9293
}
9394

9495
implFrom<Output>forCommandOutput{
9596
fnfrom(output:Output) -> Self{
96-
Self{status:output.status,stdout: output.stdout,stderr: output.stderr}
97+
Self(output)
9798
}
9899
}
99100

100101
implFrom<ExitStatus>forCommandOutput{
101102
fnfrom(status:ExitStatus) -> Self{
102-
Self{ status,stdout:Default::default(),stderr:Default::default()}
103+
Self(Output{ status,stdout:vec![],stderr:vec![]})
103104
}
104105
}

0 commit comments

Comments
 (0)