Impl From<std::process::Command> for Command

Allow creating Command from std::process::Command, similar to
what tokio::process::Command supports.
This commit is contained in:
Alexander Berger 2022-01-27 20:46:09 +01:00
parent 69789af2ca
commit 870cd2dc1f
1 changed files with 14 additions and 8 deletions

View File

@ -639,14 +639,7 @@ impl Command {
/// let mut cmd = Command::new("ls");
/// ```
pub fn new<S: AsRef<OsStr>>(program: S) -> Command {
Command {
inner: std::process::Command::new(program),
stdin: false,
stdout: false,
stderr: false,
reap_on_drop: true,
kill_on_drop: false,
}
Self::from(std::process::Command::new(program))
}
/// Adds a single argument to pass to the program.
@ -946,6 +939,19 @@ impl Command {
}
}
impl From<std::process::Command> for Command {
fn from(inner: std::process::Command) -> Self {
Self {
inner,
stdin: false,
stdout: false,
stderr: false,
reap_on_drop: true,
kill_on_drop: false,
}
}
}
impl fmt::Debug for Command {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
if f.alternate() {