File tree Expand file tree Collapse file tree 1 file changed +2
-11
lines changed Expand file tree Collapse file tree 1 file changed +2
-11
lines changed Original file line number Diff line number Diff line change @@ -464,17 +464,8 @@ impl<A: Allocator> Read for VecDeque<u8, A> {
464464
465465 #[ inline]
466466 fn read_to_string ( & mut self , buf : & mut String ) -> io:: Result < usize > {
467- // We have to use a single contiguous slice because the `VecDequeue` might be split in the
468- // middle of an UTF-8 character.
469- let len = self . len ( ) ;
470- let content = self . make_contiguous ( ) ;
471- let string = str:: from_utf8 ( content) . map_err ( |_| {
472- io:: const_io_error!( ErrorKind :: InvalidData , "stream did not contain valid UTF-8" )
473- } ) ?;
474- buf. try_reserve ( len) ?;
475- buf. push_str ( string) ;
476- self . clear ( ) ;
477- Ok ( len)
467+ // SAFETY: We only append to the buffer
468+ unsafe { io:: append_to_string ( buf, |buf| self . read_to_end ( buf) ) }
478469 }
479470}
480471
You can’t perform that action at this time.
0 commit comments