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 @@ -488,17 +488,8 @@ impl<A: Allocator> Read for VecDeque<u8, A> {
488488
489489 #[ inline]
490490 fn read_to_string ( & mut self , buf : & mut String ) -> io:: Result < usize > {
491- // We have to use a single contiguous slice because the `VecDequeue` might be split in the
492- // middle of an UTF-8 character.
493- let len = self . len ( ) ;
494- let content = self . make_contiguous ( ) ;
495- let string = str:: from_utf8 ( content) . map_err ( |_| {
496- io:: const_io_error!( ErrorKind :: InvalidData , "stream did not contain valid UTF-8" )
497- } ) ?;
498- buf. try_reserve ( len) ?;
499- buf. push_str ( string) ;
500- self . clear ( ) ;
501- Ok ( len)
491+ // SAFETY: We only append to the buffer
492+ unsafe { io:: append_to_string ( buf, |buf| self . read_to_end ( buf) ) }
502493 }
503494}
504495
You can’t perform that action at this time.
0 commit comments