diff options
| author | Alex Crichton <alex@alexcrichton.com> | 2015-07-15 23:31:24 -0700 |
|---|---|---|
| committer | Alex Crichton <alex@alexcrichton.com> | 2015-07-20 09:08:50 -0700 |
| commit | 7e9e3896dfcef4852ca8ad90f91baf5187b0248e (patch) | |
| tree | 105314b0a9e49abc7727c38c2dff96fd8d454545 /src/libstd/process.rs | |
| parent | 4e51763e6428580f2b3275cd7076492376801a1e (diff) | |
| download | rust-7e9e3896dfcef4852ca8ad90f91baf5187b0248e.tar.gz rust-7e9e3896dfcef4852ca8ad90f91baf5187b0248e.zip | |
std: Add IntoRaw{Fd,Handle,Socket} traits
This commit is an implementation of [RFC 1174][rfc] which adds three new traits to the standard library: * `IntoRawFd` - implemented on Unix for all I/O types (files, sockets, etc) * `IntoRawHandle` - implemented on Windows for files, processes, etc * `IntoRawSocket` - implemented on Windows for networking types [rfc]: https://github.com/rust-lang/rfcs/blob/master/text/1174-into-raw-fd-socket-handle-traits.md Closes #27062
Diffstat (limited to 'src/libstd/process.rs')
| -rw-r--r-- | src/libstd/process.rs | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/src/libstd/process.rs b/src/libstd/process.rs index a8127b3200f..3471805b2bc 100644 --- a/src/libstd/process.rs +++ b/src/libstd/process.rs @@ -23,7 +23,7 @@ use path; use sync::mpsc::{channel, Receiver}; use sys::pipe::{self, AnonPipe}; use sys::process as imp; -use sys_common::{AsInner, AsInnerMut, FromInner}; +use sys_common::{AsInner, AsInnerMut, FromInner, IntoInner}; use thread; /// Representation of a running or exited child process. @@ -71,6 +71,10 @@ impl AsInner<imp::Process> for Child { fn as_inner(&self) -> &imp::Process { &self.handle } } +impl IntoInner<imp::Process> for Child { + fn into_inner(self) -> imp::Process { self.handle } +} + /// A handle to a child procesess's stdin #[stable(feature = "process", since = "1.0.0")] pub struct ChildStdin { @@ -92,6 +96,10 @@ impl AsInner<AnonPipe> for ChildStdin { fn as_inner(&self) -> &AnonPipe { &self.inner } } +impl IntoInner<AnonPipe> for ChildStdin { + fn into_inner(self) -> AnonPipe { self.inner } +} + /// A handle to a child procesess's stdout #[stable(feature = "process", since = "1.0.0")] pub struct ChildStdout { @@ -109,6 +117,10 @@ impl AsInner<AnonPipe> for ChildStdout { fn as_inner(&self) -> &AnonPipe { &self.inner } } +impl IntoInner<AnonPipe> for ChildStdout { + fn into_inner(self) -> AnonPipe { self.inner } +} + /// A handle to a child procesess's stderr #[stable(feature = "process", since = "1.0.0")] pub struct ChildStderr { @@ -126,6 +138,10 @@ impl AsInner<AnonPipe> for ChildStderr { fn as_inner(&self) -> &AnonPipe { &self.inner } } +impl IntoInner<AnonPipe> for ChildStderr { + fn into_inner(self) -> AnonPipe { self.inner } +} + /// The `Command` type acts as a process builder, providing fine-grained control /// over how a new process should be spawned. A default configuration can be /// generated using `Command::new(program)`, where `program` gives a path to the |
