@@ -255,17 +255,73 @@ impl<T: super::Write> super::Write for ToStd<T> {
255
255
}
256
256
}
257
257
258
- impl < R : std:: io:: Read > super :: Read for std:: io:: BufReader < R > {
259
- #[ inline]
260
- fn read ( & mut self , buf : & mut [ u8 ] ) -> super :: Result < usize > { Ok ( std:: io:: Read :: read ( self , buf) ?) }
258
+ macro_rules! impl_our {
259
+ ( impl $( <$( $gen: ident $( : $gent: path) ?) ,* >) ? Read for $std_type: ty $( where $( $where: tt) * ) ?) => {
260
+ impl $( <$( $gen$( : $gent) ?) ,* >) ? super :: Read for $std_type $( where $( $where) * ) ? {
261
+ #[ inline]
262
+ fn read( & mut self , buf: & mut [ u8 ] ) -> super :: Result <usize > {
263
+ std:: io:: Read :: read( self , buf) . map_err( Into :: into)
264
+ }
265
+
266
+ #[ inline]
267
+ fn read_exact( & mut self , buf: & mut [ u8 ] ) -> super :: Result <( ) > {
268
+ std:: io:: Read :: read_exact( self , buf) . map_err( Into :: into)
269
+ }
270
+ }
271
+ } ;
272
+
273
+ ( impl $( <$( $gen: ident $( : $gent: path) ?) ,* >) ? BufRead for $std_type: ty $( where $( $where: tt) * ) ?) => {
274
+ impl $( <$( $gen$( : $gent) ?) ,* >) ? super :: BufRead for $std_type $( where $( $where) * ) ? {
275
+ #[ inline]
276
+ fn fill_buf( & mut self ) -> super :: Result <& [ u8 ] > {
277
+ std:: io:: BufRead :: fill_buf( self ) . map_err( Into :: into)
278
+ }
279
+
280
+ #[ inline]
281
+ fn consume( & mut self , amount: usize ) {
282
+ std:: io:: BufRead :: consume( self , amount)
283
+ }
284
+ }
285
+ } ;
286
+
287
+ ( impl $( <$( $gen: ident $( : $gent: path) ?) ,* >) ? Write for $std_type: ty $( where $( $where: tt) * ) ?) => {
288
+ impl $( <$( $gen$( : $gent) ?) ,* >) ? super :: Write for $std_type $( where $( $where) * ) ? {
289
+ #[ inline]
290
+ fn write( & mut self , buf: & [ u8 ] ) -> super :: Result <usize > {
291
+ std:: io:: Write :: write( self , buf) . map_err( Into :: into)
292
+ }
293
+
294
+ #[ inline]
295
+ fn flush( & mut self ) -> super :: Result <( ) > {
296
+ std:: io:: Write :: flush( self ) . map_err( Into :: into)
297
+ }
298
+
299
+ #[ inline]
300
+ fn write_all( & mut self , buf: & [ u8 ] ) -> super :: Result <( ) > {
301
+ std:: io:: Write :: write_all( self , buf) . map_err( Into :: into)
302
+ }
303
+ }
304
+ } ;
261
305
}
262
306
263
- impl < R : std:: io:: Read > super :: BufRead for std:: io:: BufReader < R > {
264
- #[ inline]
265
- fn fill_buf ( & mut self ) -> super :: Result < & [ u8 ] > { Ok ( std:: io:: BufRead :: fill_buf ( self ) ?) }
307
+ #[ cfg( rust_v_1_72) ]
308
+ impl_our ! {
309
+ impl <R : std:: io:: Read > Read for std:: io:: BufReader <R > where R : ?Sized
310
+ }
266
311
267
- #[ inline]
268
- fn consume ( & mut self , amount : usize ) { std:: io:: BufRead :: consume ( self , amount) }
312
+ #[ cfg( not( rust_v_1_72) ) ]
313
+ impl_our ! {
314
+ impl <R : std:: io:: Read > Read for std:: io:: BufReader <R >
315
+ }
316
+
317
+ #[ cfg( rust_v_1_72) ]
318
+ impl_our ! {
319
+ impl <R : std:: io:: Read > BufRead for std:: io:: BufReader <R > where R : ?Sized
320
+ }
321
+
322
+ #[ cfg( not( rust_v_1_72) ) ]
323
+ impl_our ! {
324
+ impl <R : std:: io:: Read > BufRead for std:: io:: BufReader <R >
269
325
}
270
326
271
327
impl std:: io:: Write for super :: Sink {
@@ -279,10 +335,12 @@ impl std::io::Write for super::Sink {
279
335
fn flush ( & mut self ) -> std:: io:: Result < ( ) > { Ok ( ( ) ) }
280
336
}
281
337
282
- impl < W : std:: io:: Write > super :: Write for std:: io:: BufWriter < W > {
283
- #[ inline]
284
- fn write ( & mut self , buf : & [ u8 ] ) -> super :: Result < usize > { Ok ( std:: io:: Write :: write ( self , buf) ?) }
338
+ #[ cfg( rust_v_1_72) ]
339
+ impl_our ! {
340
+ impl <W : std:: io:: Write > Write for std:: io:: BufWriter <W > where W : ?Sized
341
+ }
285
342
286
- #[ inline]
287
- fn flush ( & mut self ) -> super :: Result < ( ) > { Ok ( std:: io:: Write :: flush ( self ) ?) }
343
+ #[ cfg( not( rust_v_1_72) ) ]
344
+ impl_our ! {
345
+ impl <W : std:: io:: Write > Write for std:: io:: BufWriter <W >
288
346
}
0 commit comments