File tree 3 files changed +6
-5
lines changed
3 files changed +6
-5
lines changed Original file line number Diff line number Diff line change @@ -125,13 +125,10 @@ impl<R: io::Read> io::Read for Maybe<R> {
125
125
}
126
126
127
127
fn handle_ebadf < T > ( r : io:: Result < T > , default : T ) -> io:: Result < T > {
128
- #[ cfg( windows) ]
129
- const ERR : i32 = :: sys:: c:: ERROR_INVALID_HANDLE as i32 ;
130
- #[ cfg( not( windows) ) ]
131
- const ERR : i32 = :: libc:: EBADF as i32 ;
128
+ use sys:: stdio:: EBADF_ERR ;
132
129
133
130
match r {
134
- Err ( ref e) if e. raw_os_error ( ) == Some ( ERR ) => Ok ( default) ,
131
+ Err ( ref e) if e. raw_os_error ( ) == Some ( EBADF_ERR ) => Ok ( default) ,
135
132
r => r
136
133
}
137
134
}
Original file line number Diff line number Diff line change @@ -65,3 +65,5 @@ impl io::Write for Stderr {
65
65
}
66
66
fn flush ( & mut self ) -> io:: Result < ( ) > { Ok ( ( ) ) }
67
67
}
68
+
69
+ pub const EBADF_ERR : i32 = :: libc:: EBADF as i32 ;
Original file line number Diff line number Diff line change @@ -205,3 +205,5 @@ impl Output {
205
205
fn invalid_encoding ( ) -> io:: Error {
206
206
io:: Error :: new ( io:: ErrorKind :: InvalidData , "text was not valid unicode" )
207
207
}
208
+
209
+ pub const EBADF_ERR : i32 = :: sys:: c:: ERROR_INVALID_HANDLE as i32 ;
You can’t perform that action at this time.
0 commit comments