File tree 3 files changed +41
-0
lines changed
3 files changed +41
-0
lines changed Original file line number Diff line number Diff line change @@ -194,3 +194,22 @@ impl ChildExt for process::Child {
194
194
self . handle . main_thread_handle ( )
195
195
}
196
196
}
197
+
198
+ /// Windows-specific extensions to [`process::ExitCode`].
199
+ ///
200
+ /// This trait is sealed: it cannot be implemented outside the standard library.
201
+ /// This is so that future additional methods are not breaking changes.
202
+ #[ stable( feature = "windows_process_exit_code_from" , since = "1.63.0" ) ]
203
+ pub trait ExitCodeExt : Sealed {
204
+ /// Creates a new `ExitStatus` from the raw underlying `u32` return value of
205
+ /// a process.
206
+ #[ stable( feature = "windows_process_exit_code_from" , since = "1.63.0" ) ]
207
+ fn from_raw ( raw : u32 ) -> Self ;
208
+ }
209
+
210
+ #[ stable( feature = "windows_process_exit_code_from" , since = "1.63.0" ) ]
211
+ impl ExitCodeExt for process:: ExitCode {
212
+ fn from_raw ( raw : u32 ) -> Self {
213
+ process:: ExitCode :: from_inner ( From :: from ( raw) )
214
+ }
215
+ }
Original file line number Diff line number Diff line change @@ -1708,6 +1708,10 @@ impl crate::error::Error for ExitStatusError {}
1708
1708
#[ stable( feature = "process_exitcode" , since = "1.61.0" ) ]
1709
1709
pub struct ExitCode ( imp:: ExitCode ) ;
1710
1710
1711
+ /// Allows extension traits within `std`.
1712
+ #[ unstable( feature = "sealed" , issue = "none" ) ]
1713
+ impl crate :: sealed:: Sealed for ExitCode { }
1714
+
1711
1715
#[ stable( feature = "process_exitcode" , since = "1.61.0" ) ]
1712
1716
impl ExitCode {
1713
1717
/// The canonical `ExitCode` for successful termination on this platform.
@@ -1798,6 +1802,18 @@ impl From<u8> for ExitCode {
1798
1802
}
1799
1803
}
1800
1804
1805
+ impl AsInner < imp:: ExitCode > for ExitCode {
1806
+ fn as_inner ( & self ) -> & imp:: ExitCode {
1807
+ & self . 0
1808
+ }
1809
+ }
1810
+
1811
+ impl FromInner < imp:: ExitCode > for ExitCode {
1812
+ fn from_inner ( s : imp:: ExitCode ) -> ExitCode {
1813
+ ExitCode ( s)
1814
+ }
1815
+ }
1816
+
1801
1817
impl Child {
1802
1818
/// Forces the child process to exit. If the child has already exited, an [`InvalidInput`]
1803
1819
/// error is returned.
Original file line number Diff line number Diff line change @@ -707,6 +707,12 @@ impl From<u8> for ExitCode {
707
707
}
708
708
}
709
709
710
+ impl From < u32 > for ExitCode {
711
+ fn from ( code : u32 ) -> Self {
712
+ ExitCode ( c:: DWORD :: from ( code) )
713
+ }
714
+ }
715
+
710
716
fn zeroed_startupinfo ( ) -> c:: STARTUPINFO {
711
717
c:: STARTUPINFO {
712
718
cb : 0 ,
You can’t perform that action at this time.
0 commit comments