File tree Expand file tree Collapse file tree 3 files changed +29
-1
lines changed Expand file tree Collapse file tree 3 files changed +29
-1
lines changed Original file line number Diff line number Diff line change @@ -357,6 +357,28 @@ where
357
357
self . pos += n as u64 ;
358
358
Ok ( ( ) )
359
359
}
360
+
361
+ fn read_to_end ( & mut self , buf : & mut Vec < u8 > ) -> io:: Result < usize > {
362
+ let content = self . remaining_slice ( ) ;
363
+ let len = content. len ( ) ;
364
+ buf. try_reserve ( len) ?;
365
+ buf. extend_from_slice ( content) ;
366
+ self . pos += len as u64 ;
367
+
368
+ Ok ( len)
369
+ }
370
+
371
+ fn read_to_string ( & mut self , buf : & mut String ) -> io:: Result < usize > {
372
+ let content = crate :: str:: from_utf8 ( self . remaining_slice ( ) ) . map_err ( |_| {
373
+ io:: const_io_error!( ErrorKind :: InvalidData , "stream did not contain valid UTF-8" )
374
+ } ) ?;
375
+ let len = content. len ( ) ;
376
+ buf. try_reserve ( len) ?;
377
+ buf. push_str ( content) ;
378
+ self . pos += len as u64 ;
379
+
380
+ Ok ( len)
381
+ }
360
382
}
361
383
362
384
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
Original file line number Diff line number Diff line change @@ -315,8 +315,9 @@ impl Read for &[u8] {
315
315
let content = str:: from_utf8 ( self ) . map_err ( |_| {
316
316
io:: const_io_error!( ErrorKind :: InvalidData , "stream did not contain valid UTF-8" )
317
317
} ) ?;
318
- buf. push_str ( content) ;
319
318
let len = self . len ( ) ;
319
+ buf. try_reserve ( len) ?;
320
+ buf. push_str ( content) ;
320
321
* self = & self [ len..] ;
321
322
Ok ( len)
322
323
}
@@ -470,6 +471,7 @@ impl<A: Allocator> Read for VecDeque<u8, A> {
470
471
let string = str:: from_utf8 ( content) . map_err ( |_| {
471
472
io:: const_io_error!( ErrorKind :: InvalidData , "stream did not contain valid UTF-8" )
472
473
} ) ?;
474
+ buf. try_reserve ( len) ?;
473
475
buf. push_str ( string) ;
474
476
self . clear ( ) ;
475
477
Ok ( len)
Original file line number Diff line number Diff line change @@ -439,6 +439,10 @@ impl Read for ChildStderr {
439
439
fn is_read_vectored ( & self ) -> bool {
440
440
self . inner . is_read_vectored ( )
441
441
}
442
+
443
+ fn read_to_end ( & mut self , buf : & mut Vec < u8 > ) -> io:: Result < usize > {
444
+ self . inner . read_to_end ( buf)
445
+ }
442
446
}
443
447
444
448
impl AsInner < AnonPipe > for ChildStderr {
You can’t perform that action at this time.
0 commit comments