File tree 5 files changed +42
-0
lines changed
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 {
605
605
fn as_inner ( & self ) -> & imp:: ExitStatus { & self . 0 }
606
606
}
607
607
608
+ impl FromInner < imp:: ExitStatus > for ExitStatus {
609
+ fn from_inner ( s : imp:: ExitStatus ) -> ExitStatus {
610
+ ExitStatus ( s)
611
+ }
612
+ }
613
+
608
614
#[ stable( feature = "process" , since = "1.0.0" ) ]
609
615
impl fmt:: Display for ExitStatus {
610
616
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 {
132
132
/// Unix-specific extensions to `std::process::ExitStatus`
133
133
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
134
134
pub 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
+
135
140
/// If the process was terminated by a signal, returns that signal.
136
141
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
137
142
fn signal ( & self ) -> Option < i32 > ;
138
143
}
139
144
140
145
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
141
146
impl ExitStatusExt for process:: ExitStatus {
147
+ fn from_raw ( raw : i32 ) -> Self {
148
+ process:: ExitStatus :: from_inner ( From :: from ( raw) )
149
+ }
150
+
142
151
fn signal ( & self ) -> Option < i32 > {
143
152
self . as_inner ( ) . signal ( )
144
153
}
Original file line number Diff line number Diff line change @@ -550,6 +550,12 @@ impl ExitStatus {
550
550
}
551
551
}
552
552
553
+ impl From < c_int > for ExitStatus {
554
+ fn from ( a : c_int ) -> ExitStatus {
555
+ ExitStatus ( a)
556
+ }
557
+ }
558
+
553
559
impl fmt:: Display for ExitStatus {
554
560
fn fmt ( & self , f : & mut fmt:: Formatter ) -> fmt:: Result {
555
561
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 {
81
81
self . into_inner ( ) . into_handle ( ) . into_raw ( ) as * mut _
82
82
}
83
83
}
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 {
337
337
}
338
338
}
339
339
340
+ impl From < c:: DWORD > for ExitStatus {
341
+ fn from ( u : c:: DWORD ) -> ExitStatus {
342
+ ExitStatus ( u)
343
+ }
344
+ }
345
+
340
346
impl fmt:: Display for ExitStatus {
341
347
fn fmt ( & self , f : & mut fmt:: Formatter ) -> fmt:: Result {
342
348
write ! ( f, "exit code: {}" , self . 0 )
You can’t perform that action at this time.
0 commit comments