diff options
| author | Mara Bos <m-ou.se@m-ou.se> | 2021-08-04 14:15:05 +0200 |
|---|---|---|
| committer | Mara Bos <m-ou.se@m-ou.se> | 2021-08-04 14:15:05 +0200 |
| commit | f280a126b291bf7f6040db1214cdad5877811b6d (patch) | |
| tree | 12a70877e8d833be008b28798067a0d3af438b2a | |
| parent | d08460e70cd77945ecfa6f4826c82ed4ba29fb76 (diff) | |
| download | rust-f280a126b291bf7f6040db1214cdad5877811b6d.tar.gz rust-f280a126b291bf7f6040db1214cdad5877811b6d.zip | |
Re-use std::sealed::Sealed in os/linux/process.
| -rw-r--r-- | library/std/src/os/linux/process.rs | 15 | ||||
| -rw-r--r-- | library/std/src/process.rs | 4 |
2 files changed, 7 insertions, 12 deletions
diff --git a/library/std/src/os/linux/process.rs b/library/std/src/os/linux/process.rs index 91547b8f916..6daff0f003c 100644 --- a/library/std/src/os/linux/process.rs +++ b/library/std/src/os/linux/process.rs @@ -5,6 +5,7 @@ use crate::io::Result; use crate::os::unix::io::{AsRawFd, FromRawFd, IntoRawFd, RawFd}; use crate::process; +use crate::sealed::Sealed; #[cfg(not(doc))] use crate::sys::fd::FileDesc; use crate::sys_common::{AsInner, AsInnerMut, FromInner, IntoInner}; @@ -84,15 +85,10 @@ impl IntoRawFd for PidFd { } } -mod private_child_ext { - pub trait Sealed {} - impl Sealed for crate::process::Child {} -} - /// Os-specific extensions for [`Child`] /// /// [`Child`]: process::Child -pub trait ChildExt: private_child_ext::Sealed { +pub trait ChildExt: Sealed { /// Obtains a reference to the [`PidFd`] created for this [`Child`], if available. /// /// A pidfd will only be available if its creation was requested with @@ -120,15 +116,10 @@ pub trait ChildExt: private_child_ext::Sealed { fn take_pidfd(&mut self) -> Result<PidFd>; } -mod private_command_ext { - pub trait Sealed {} - impl Sealed for crate::process::Command {} -} - /// Os-specific extensions for [`Command`] /// /// [`Command`]: process::Command -pub trait CommandExt: private_command_ext::Sealed { +pub trait CommandExt: Sealed { /// Sets whether a [`PidFd`](struct@PidFd) should be created for the [`Child`] /// spawned by this [`Command`]. /// By default, no pidfd will be created. diff --git a/library/std/src/process.rs b/library/std/src/process.rs index 99c3369425b..d3e271df8d8 100644 --- a/library/std/src/process.rs +++ b/library/std/src/process.rs @@ -205,6 +205,10 @@ pub struct Child { pub stderr: Option<ChildStderr>, } +/// Allows extension traits within `std`. +#[unstable(feature = "sealed", issue = "none")] +impl crate::sealed::Sealed for Child {} + impl AsInner<imp::Process> for Child { fn as_inner(&self) -> &imp::Process { &self.handle |
