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 @@ -364,6 +364,28 @@ where
364
364
self . pos += n as u64 ;
365
365
Ok ( ( ) )
366
366
}
367
+
368
+ fn read_to_end ( & mut self , buf : & mut Vec < u8 > ) -> io:: Result < usize > {
369
+ let content = self . remaining_slice ( ) ;
370
+ let len = content. len ( ) ;
371
+ buf. try_reserve ( len) ?;
372
+ buf. extend_from_slice ( content) ;
373
+ self . pos += len as u64 ;
374
+
375
+ Ok ( len)
376
+ }
377
+
378
+ fn read_to_string ( & mut self , buf : & mut String ) -> io:: Result < usize > {
379
+ let content = crate :: str:: from_utf8 ( self . remaining_slice ( ) ) . map_err ( |_| {
380
+ io:: const_io_error!( ErrorKind :: InvalidData , "stream did not contain valid UTF-8" )
381
+ } ) ?;
382
+ let len = content. len ( ) ;
383
+ buf. try_reserve ( len) ?;
384
+ buf. push_str ( content) ;
385
+ self . pos += len as u64 ;
386
+
387
+ Ok ( len)
388
+ }
367
389
}
368
390
369
391
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
Original file line number Diff line number Diff line change @@ -339,8 +339,9 @@ impl Read for &[u8] {
339
339
let content = str:: from_utf8 ( self ) . map_err ( |_| {
340
340
io:: const_io_error!( ErrorKind :: InvalidData , "stream did not contain valid UTF-8" )
341
341
} ) ?;
342
- buf. push_str ( content) ;
343
342
let len = self . len ( ) ;
343
+ buf. try_reserve ( len) ?;
344
+ buf. push_str ( content) ;
344
345
* self = & self [ len..] ;
345
346
Ok ( len)
346
347
}
@@ -494,6 +495,7 @@ impl<A: Allocator> Read for VecDeque<u8, A> {
494
495
let string = str:: from_utf8 ( content) . map_err ( |_| {
495
496
io:: const_io_error!( ErrorKind :: InvalidData , "stream did not contain valid UTF-8" )
496
497
} ) ?;
498
+ buf. try_reserve ( len) ?;
497
499
buf. push_str ( string) ;
498
500
self . clear ( ) ;
499
501
Ok ( len)
Original file line number Diff line number Diff line change @@ -486,6 +486,10 @@ impl Read for ChildStderr {
486
486
fn is_read_vectored ( & self ) -> bool {
487
487
self . inner . is_read_vectored ( )
488
488
}
489
+
490
+ fn read_to_end ( & mut self , buf : & mut Vec < u8 > ) -> io:: Result < usize > {
491
+ self . inner . read_to_end ( buf)
492
+ }
489
493
}
490
494
491
495
impl AsInner < AnonPipe > for ChildStderr {
You can’t perform that action at this time.
0 commit comments