Skip to content

Commit 2807f28

Browse files
authored
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); ```
2 parents 85f1de2 + 8b93147 commit 2807f28

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

Diff for: library/std/src/process.rs

+16
Original file line numberDiff line numberDiff line change
@@ -1273,6 +1273,22 @@ impl Stdio {
12731273
pub fn null() -> Stdio {
12741274
Stdio(imp::Stdio::Null)
12751275
}
1276+
1277+
/// Returns `true` if this requires [`Command`] to create a new pipe.
1278+
///
1279+
/// # Example
1280+
///
1281+
/// ```
1282+
/// #![feature(stdio_makes_pipe)]
1283+
/// use std::process::Stdio;
1284+
///
1285+
/// let io = Stdio::piped();
1286+
/// assert_eq!(io.makes_pipe(), true);
1287+
/// ```
1288+
#[unstable(feature = "stdio_makes_pipe", issue = "98288")]
1289+
pub fn makes_pipe(&self) -> bool {
1290+
matches!(self.0, imp::Stdio::MakePipe)
1291+
}
12761292
}
12771293

12781294
impl FromInner<imp::Stdio> for Stdio {

0 commit comments

Comments
 (0)