From b1ea12e115df479d0069c8bdc3cae6a0b2675170 Mon Sep 17 00:00:00 2001 From: Ivan Petkov Date: Thu, 2 Dec 2021 11:02:26 -0800 Subject: [PATCH] process: Add `as_std()` method to `Command` * This allows callers to cheaply convert to a &std::process::Command and use any (immutable) methods added on the stdlib type in case they are missing from our own wrapper (e.g. because MSRV is lagging) --- tokio/src/process/mod.rs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/tokio/src/process/mod.rs b/tokio/src/process/mod.rs index 6eeefdbef71..8a0d9db25fd 100644 --- a/tokio/src/process/mod.rs +++ b/tokio/src/process/mod.rs @@ -264,6 +264,12 @@ impl Command { Self::from(StdCommand::new(program)) } + /// Cheaply convert to a `&std::process::Command` for places where the type from the standard + /// library is expected. + pub fn as_std(&self) -> &StdCommand { + &self.std + } + /// Adds an argument to pass to the program. /// /// Only one argument can be passed per use. So instead of: