File tree Expand file tree Collapse file tree 3 files changed +28
-1
lines changed Expand file tree Collapse file tree 3 files changed +28
-1
lines changed Original file line number Diff line number Diff line change @@ -364,6 +364,27 @@ where
364364 self . pos += n as u64 ;
365365 Ok ( ( ) )
366366 }
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 =
380+ crate :: str:: from_utf8 ( self . remaining_slice ( ) ) . map_err ( |_| io:: Error :: INVALID_UTF8 ) ?;
381+ let len = content. len ( ) ;
382+ buf. try_reserve ( len) ?;
383+ buf. push_str ( content) ;
384+ self . pos += len as u64 ;
385+
386+ Ok ( len)
387+ }
367388}
368389
369390#[ stable( feature = "rust1" , since = "1.0.0" ) ]
Original file line number Diff line number Diff line change @@ -329,8 +329,9 @@ impl Read for &[u8] {
329329 #[ inline]
330330 fn read_to_string ( & mut self , buf : & mut String ) -> io:: Result < usize > {
331331 let content = str:: from_utf8 ( self ) . map_err ( |_| io:: Error :: INVALID_UTF8 ) ?;
332- buf. push_str ( content) ;
333332 let len = self . len ( ) ;
333+ buf. try_reserve ( len) ?;
334+ buf. push_str ( content) ;
334335 * self = & self [ len..] ;
335336 Ok ( len)
336337 }
@@ -478,6 +479,7 @@ impl<A: Allocator> Read for VecDeque<u8, A> {
478479 let len = self . len ( ) ;
479480 let content = self . make_contiguous ( ) ;
480481 let string = str:: from_utf8 ( content) . map_err ( |_| io:: Error :: INVALID_UTF8 ) ?;
482+ buf. try_reserve ( len) ?;
481483 buf. push_str ( string) ;
482484 self . clear ( ) ;
483485 Ok ( len)
Original file line number Diff line number Diff line change @@ -486,6 +486,10 @@ impl Read for ChildStderr {
486486 fn is_read_vectored ( & self ) -> bool {
487487 self . inner . is_read_vectored ( )
488488 }
489+
490+ fn read_to_end ( & mut self , buf : & mut Vec < u8 > ) -> io:: Result < usize > {
491+ self . inner . read_to_end ( buf)
492+ }
489493}
490494
491495impl AsInner < AnonPipe > for ChildStderr {
You can’t perform that action at this time.
0 commit comments