diff options
| author | Dylan DPC <99973273+Dylan-DPC@users.noreply.github.com> | 2022-06-20 14:56:39 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-06-20 14:56:39 +0200 |
| commit | 2807f28de550fb6074dc4fb2f3099865de01bc1e (patch) | |
| tree | d802ff7aad133ce915f938b71f199cc564e7ae47 | |
| parent | 85f1de20e76001db54d64ee0c3f9fec797075938 (diff) | |
| parent | 8b93147f7e1805a8910f0d593aacf87f539a1280 (diff) | |
| download | rust-2807f28de550fb6074dc4fb2f3099865de01bc1e.tar.gz rust-2807f28de550fb6074dc4fb2f3099865de01bc1e.zip | |
Rollup merge of #97150 - ChrisDenton:stdio-create_pipe, r=m-ou-se
`Stdio::makes_pipe` Wrappers around `std::process::Command` may want to be able to override pipe creation. However, [`std::process::Stdio`](https://doc.rust-lang.org/std/process/struct.Stdio.html) is opaque so there's no way to tell if `Command` was told to create new pipes or not. This is in some ways a more generic (and cross-platform) alternative to #97149. However, unlike that feature, this comes with the price of the user needing to actually create their own pipes rather than reusing the std one. So I think it stands (or not) on its own. # Example ```rust #![feature(stdio_makes_pipe)] use std::process::Stdio; let io = Stdio::piped(); assert_eq!(io.makes_pipe(), true); ```
| -rw-r--r-- | library/std/src/process.rs | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/library/std/src/process.rs b/library/std/src/process.rs index da8eee9030b..ab1a1e6c76f 100644 --- a/library/std/src/process.rs +++ b/library/std/src/process.rs @@ -1273,6 +1273,22 @@ impl Stdio { pub fn null() -> Stdio { Stdio(imp::Stdio::Null) } + + /// Returns `true` if this requires [`Command`] to create a new pipe. + /// + /// # Example + /// + /// ``` + /// #![feature(stdio_makes_pipe)] + /// use std::process::Stdio; + /// + /// let io = Stdio::piped(); + /// assert_eq!(io.makes_pipe(), true); + /// ``` + #[unstable(feature = "stdio_makes_pipe", issue = "98288")] + pub fn makes_pipe(&self) -> bool { + matches!(self.0, imp::Stdio::MakePipe) + } } impl FromInner<imp::Stdio> for Stdio { |
