File tree Expand file tree Collapse file tree 2 files changed +4
-5
lines changed
compiler/rustc_serialize/src Expand file tree Collapse file tree 2 files changed +4
-5
lines changed Original file line number Diff line number Diff line change 11use crate :: leb128:: { self , max_leb128_len} ;
22use crate :: serialize:: { self , Encoder as _} ;
3- use std:: borrow:: Cow ;
43use std:: convert:: TryInto ;
54use std:: fs:: File ;
65use std:: io:: { self , Write } ;
@@ -663,15 +662,15 @@ impl<'a> serialize::Decoder for Decoder<'a> {
663662 }
664663
665664 #[ inline]
666- fn read_str ( & mut self ) -> Cow < ' _ , str > {
665+ fn read_str ( & mut self ) -> & str {
667666 let len = self . read_usize ( ) ;
668667 let sentinel = self . data [ self . position + len] ;
669668 assert ! ( sentinel == STR_SENTINEL ) ;
670669 let s = unsafe {
671670 std:: str:: from_utf8_unchecked ( & self . data [ self . position ..self . position + len] )
672671 } ;
673672 self . position += len + 1 ;
674- Cow :: Borrowed ( s )
673+ s
675674 }
676675
677676 #[ inline]
Original file line number Diff line number Diff line change @@ -198,7 +198,7 @@ pub trait Decoder {
198198 fn read_f64 ( & mut self ) -> f64 ;
199199 fn read_f32 ( & mut self ) -> f32 ;
200200 fn read_char ( & mut self ) -> char ;
201- fn read_str ( & mut self ) -> Cow < ' _ , str > ;
201+ fn read_str ( & mut self ) -> & str ;
202202 fn read_raw_bytes_into ( & mut self , s : & mut [ u8 ] ) ;
203203}
204204
@@ -313,7 +313,7 @@ impl<S: Encoder> Encodable<S> for String {
313313
314314impl < D : Decoder > Decodable < D > for String {
315315 fn decode ( d : & mut D ) -> String {
316- d. read_str ( ) . into_owned ( )
316+ d. read_str ( ) . to_owned ( )
317317 }
318318}
319319
You can’t perform that action at this time.
0 commit comments