File tree 2 files changed +4
-5
lines changed
compiler/rustc_serialize/src
2 files changed +4
-5
lines changed Original file line number Diff line number Diff line change 1
1
use crate :: leb128:: { self , max_leb128_len} ;
2
2
use crate :: serialize:: { self , Encoder as _} ;
3
- use std:: borrow:: Cow ;
4
3
use std:: convert:: TryInto ;
5
4
use std:: fs:: File ;
6
5
use std:: io:: { self , Write } ;
@@ -663,15 +662,15 @@ impl<'a> serialize::Decoder for Decoder<'a> {
663
662
}
664
663
665
664
#[ inline]
666
- fn read_str ( & mut self ) -> Cow < ' _ , str > {
665
+ fn read_str ( & mut self ) -> & str {
667
666
let len = self . read_usize ( ) ;
668
667
let sentinel = self . data [ self . position + len] ;
669
668
assert ! ( sentinel == STR_SENTINEL ) ;
670
669
let s = unsafe {
671
670
std:: str:: from_utf8_unchecked ( & self . data [ self . position ..self . position + len] )
672
671
} ;
673
672
self . position += len + 1 ;
674
- Cow :: Borrowed ( s )
673
+ s
675
674
}
676
675
677
676
#[ inline]
Original file line number Diff line number Diff line change @@ -198,7 +198,7 @@ pub trait Decoder {
198
198
fn read_f64 ( & mut self ) -> f64 ;
199
199
fn read_f32 ( & mut self ) -> f32 ;
200
200
fn read_char ( & mut self ) -> char ;
201
- fn read_str ( & mut self ) -> Cow < ' _ , str > ;
201
+ fn read_str ( & mut self ) -> & str ;
202
202
fn read_raw_bytes_into ( & mut self , s : & mut [ u8 ] ) ;
203
203
}
204
204
@@ -313,7 +313,7 @@ impl<S: Encoder> Encodable<S> for String {
313
313
314
314
impl < D : Decoder > Decodable < D > for String {
315
315
fn decode ( d : & mut D ) -> String {
316
- d. read_str ( ) . into_owned ( )
316
+ d. read_str ( ) . to_owned ( )
317
317
}
318
318
}
319
319
You can’t perform that action at this time.
0 commit comments