File tree Expand file tree Collapse file tree 3 files changed +41
-0
lines changed Expand file tree Collapse file tree 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 {
194194 self . handle . main_thread_handle ( )
195195 }
196196}
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 {}
17081708#[ stable( feature = "process_exitcode" , since = "1.61.0" ) ]
17091709pub struct ExitCode ( imp:: ExitCode ) ;
17101710
1711+ /// Allows extension traits within `std`.
1712+ #[ unstable( feature = "sealed" , issue = "none" ) ]
1713+ impl crate :: sealed:: Sealed for ExitCode { }
1714+
17111715#[ stable( feature = "process_exitcode" , since = "1.61.0" ) ]
17121716impl ExitCode {
17131717 /// The canonical `ExitCode` for successful termination on this platform.
@@ -1798,6 +1802,18 @@ impl From<u8> for ExitCode {
17981802 }
17991803}
18001804
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+
18011817impl Child {
18021818 /// Forces the child process to exit. If the child has already exited, an [`InvalidInput`]
18031819 /// error is returned.
Original file line number Diff line number Diff line change @@ -707,6 +707,12 @@ impl From<u8> for ExitCode {
707707 }
708708}
709709
710+ impl From < u32 > for ExitCode {
711+ fn from ( code : u32 ) -> Self {
712+ ExitCode ( c:: DWORD :: from ( code) )
713+ }
714+ }
715+
710716fn zeroed_startupinfo ( ) -> c:: STARTUPINFO {
711717 c:: STARTUPINFO {
712718 cb : 0 ,
You can’t perform that action at this time.
0 commit comments