Skip to content

Commit f76d325

Browse files
committed
Seal CommandExt trait
This is technically a breaking change, but we follow the standard library's decision that sealing CommandExt is fine. rust-lang/rust@bfd1ccf
1 parent 7980b46 commit f76d325

File tree

3 files changed

+14
-2
lines changed

3 files changed

+14
-2
lines changed

src/lib.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,10 @@ pub mod unix;
8282
#[cfg(windows)]
8383
pub mod windows;
8484

85+
mod sealed {
86+
pub trait Sealed {}
87+
}
88+
8589
/// An event delivered every time the SIGCHLD signal occurs.
8690
static SIGCHLD: Event = Event::new();
8791

src/unix.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,10 @@ use std::os::unix::process::CommandExt as _;
77
use crate::Command;
88

99
/// Unix-specific extensions to the [`Command`] builder.
10-
pub trait CommandExt {
10+
///
11+
/// This trait is sealed: it cannot be implemented outside `async-process`.
12+
/// This is so that future additional methods are not breaking changes.
13+
pub trait CommandExt: crate::sealed::Sealed {
1114
/// Sets the child process's user ID. This translates to a
1215
/// `setuid` call in the child process. Failure in the `setuid`
1316
/// call will cause the spawn to fail.
@@ -88,6 +91,7 @@ pub trait CommandExt {
8891
S: AsRef<OsStr>;
8992
}
9093

94+
impl crate::sealed::Sealed for Command {}
9195
impl CommandExt for Command {
9296
fn uid(&mut self, id: u32) -> &mut Command {
9397
self.inner.uid(id);

src/windows.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,10 @@ use std::os::windows::process::CommandExt as _;
66
use crate::{Child, Command};
77

88
/// Windows-specific extensions to the [`Command`] builder.
9-
pub trait CommandExt {
9+
///
10+
/// This trait is sealed: it cannot be implemented outside `async-process`.
11+
/// This is so that future additional methods are not breaking changes.
12+
pub trait CommandExt: crate::sealed::Sealed {
1013
/// Sets the [process creation flags][1] to be passed to `CreateProcess`.
1114
///
1215
/// These will always be ORed with `CREATE_UNICODE_ENVIRONMENT`.
@@ -15,6 +18,7 @@ pub trait CommandExt {
1518
fn creation_flags(&mut self, flags: u32) -> &mut Command;
1619
}
1720

21+
impl crate::sealed::Sealed for Command {}
1822
impl CommandExt for Command {
1923
fn creation_flags(&mut self, flags: u32) -> &mut Command {
2024
self.inner.creation_flags(flags);

0 commit comments

Comments
 (0)