File tree Expand file tree Collapse file tree 5 files changed +42
-0
lines changed Expand file tree Collapse file tree 5 files changed +42
-0
lines changed Original file line number Diff line number Diff line change @@ -605,6 +605,12 @@ impl AsInner<imp::ExitStatus> for ExitStatus {
605605 fn as_inner ( & self ) -> & imp:: ExitStatus { & self . 0 }
606606}
607607
608+ impl FromInner < imp:: ExitStatus > for ExitStatus {
609+ fn from_inner ( s : imp:: ExitStatus ) -> ExitStatus {
610+ ExitStatus ( s)
611+ }
612+ }
613+
608614#[ stable( feature = "process" , since = "1.0.0" ) ]
609615impl fmt:: Display for ExitStatus {
610616 fn fmt ( & self , f : & mut fmt:: Formatter ) -> fmt:: Result {
Original file line number Diff line number Diff line change @@ -132,13 +132,22 @@ impl CommandExt for process::Command {
132132/// Unix-specific extensions to `std::process::ExitStatus`
133133#[ stable( feature = "rust1" , since = "1.0.0" ) ]
134134pub trait ExitStatusExt {
135+ /// Creates a new `ExitStatus` from the raw underlying `i32` return value of
136+ /// a process.
137+ #[ unstable( feature = "exit_status_from" , issue = "32713" ) ]
138+ fn from_raw ( raw : i32 ) -> Self ;
139+
135140 /// If the process was terminated by a signal, returns that signal.
136141 #[ stable( feature = "rust1" , since = "1.0.0" ) ]
137142 fn signal ( & self ) -> Option < i32 > ;
138143}
139144
140145#[ stable( feature = "rust1" , since = "1.0.0" ) ]
141146impl ExitStatusExt for process:: ExitStatus {
147+ fn from_raw ( raw : i32 ) -> Self {
148+ process:: ExitStatus :: from_inner ( From :: from ( raw) )
149+ }
150+
142151 fn signal ( & self ) -> Option < i32 > {
143152 self . as_inner ( ) . signal ( )
144153 }
Original file line number Diff line number Diff line change @@ -550,6 +550,12 @@ impl ExitStatus {
550550 }
551551}
552552
553+ impl From < c_int > for ExitStatus {
554+ fn from ( a : c_int ) -> ExitStatus {
555+ ExitStatus ( a)
556+ }
557+ }
558+
553559impl fmt:: Display for ExitStatus {
554560 fn fmt ( & self , f : & mut fmt:: Formatter ) -> fmt:: Result {
555561 if let Some ( code) = self . code ( ) {
Original file line number Diff line number Diff line change @@ -81,3 +81,18 @@ impl IntoRawHandle for process::ChildStderr {
8181 self . into_inner ( ) . into_handle ( ) . into_raw ( ) as * mut _
8282 }
8383}
84+
85+ /// Windows-specific extensions to `std::process::ExitStatus`
86+ #[ unstable( feature = "exit_status_from" , issue = "32713" ) ]
87+ pub trait ExitStatusExt {
88+ /// Creates a new `ExitStatus` from the raw underlying `u32` return value of
89+ /// a process.
90+ fn from_raw ( raw : u32 ) -> Self ;
91+ }
92+
93+ #[ stable( feature = "rust1" , since = "1.0.0" ) ]
94+ impl ExitStatusExt for process:: ExitStatus {
95+ fn from_raw ( raw : u32 ) -> Self {
96+ process:: ExitStatus :: from_inner ( From :: from ( raw) )
97+ }
98+ }
Original file line number Diff line number Diff line change @@ -337,6 +337,12 @@ impl ExitStatus {
337337 }
338338}
339339
340+ impl From < c:: DWORD > for ExitStatus {
341+ fn from ( u : c:: DWORD ) -> ExitStatus {
342+ ExitStatus ( u)
343+ }
344+ }
345+
340346impl fmt:: Display for ExitStatus {
341347 fn fmt ( & self , f : & mut fmt:: Formatter ) -> fmt:: Result {
342348 write ! ( f, "exit code: {}" , self . 0 )
You can’t perform that action at this time.
0 commit comments