about summary refs log tree commit diff
path: root/src/libstd/sys/windows/ext
diff options
context:
space:
mode:
authorAlex Crichton <alex@alexcrichton.com>2016-04-26 15:23:46 -0700
committerAlex Crichton <alex@alexcrichton.com>2016-04-26 23:35:59 -0700
commit7f09b1f6a64339370440025d50d0ad4a7f239734 (patch)
tree48c65ea79997aa1193467936a1ecadd5091a317d /src/libstd/sys/windows/ext
parent092b0738b7f00740c997a3fb99dd0b8b50c4c157 (diff)
downloadrust-7f09b1f6a64339370440025d50d0ad4a7f239734.tar.gz
rust-7f09b1f6a64339370440025d50d0ad4a7f239734.zip
std: Allow creating ExitStatus from raw values
Sometimes a process may be waited on externally from the standard library, in
which case it can be useful to create a raw `ExitStatus` structure to return.
This commit extends the existing Unix `ExitStatusExt` extension trait and adds a
new Windows-specific `ExitStatusExt` extension trait to do this. The methods are
currently called `ExitStatus::from_raw`.

cc #32713
Diffstat (limited to 'src/libstd/sys/windows/ext')
-rw-r--r--src/libstd/sys/windows/ext/process.rs15
1 files changed, 15 insertions, 0 deletions
diff --git a/src/libstd/sys/windows/ext/process.rs b/src/libstd/sys/windows/ext/process.rs
index f6ee59eec32..56c6a73d4f8 100644
--- a/src/libstd/sys/windows/ext/process.rs
+++ b/src/libstd/sys/windows/ext/process.rs
@@ -81,3 +81,18 @@ impl IntoRawHandle for process::ChildStderr {
         self.into_inner().into_handle().into_raw() as *mut _
     }
 }
+
+/// Windows-specific extensions to `std::process::ExitStatus`
+#[unstable(feature = "exit_status_from", issue = "32713")]
+pub trait ExitStatusExt {
+    /// Creates a new `ExitStatus` from the raw underlying `u32` return value of
+    /// a process.
+    fn from_raw(raw: u32) -> Self;
+}
+
+#[stable(feature = "rust1", since = "1.0.0")]
+impl ExitStatusExt for process::ExitStatus {
+    fn from_raw(raw: u32) -> Self {
+        process::ExitStatus::from_inner(From::from(raw))
+    }
+}