@@ -5,7 +5,7 @@ use crate::{
5
5
parser:: parse_expression_located,
6
6
token:: StringKind ,
7
7
} ;
8
- use std:: { iter, mem , str} ;
8
+ use std:: { iter, str} ;
9
9
10
10
/// unicode_name2 does not expose `MAX_NAME_LENGTH`, so we replicate that constant here, fix #3798
11
11
pub const MAX_UNICODE_NAME : usize = 88 ;
@@ -365,10 +365,9 @@ impl<'a> StringParser<'a> {
365
365
'{' => {
366
366
if !constant_piece. is_empty ( ) {
367
367
spec_constructor. push ( self . expr ( ExprKind :: Constant {
368
- value : constant_piece. to_owned ( ) . into ( ) ,
368
+ value : constant_piece. drain ( .. ) . collect :: < String > ( ) . into ( ) ,
369
369
kind : None ,
370
370
} ) ) ;
371
- constant_piece. clear ( ) ;
372
371
}
373
372
let parsed_expr = self . parse_fstring ( nested + 1 ) ?;
374
373
spec_constructor. extend ( parsed_expr) ;
@@ -385,10 +384,9 @@ impl<'a> StringParser<'a> {
385
384
}
386
385
if !constant_piece. is_empty ( ) {
387
386
spec_constructor. push ( self . expr ( ExprKind :: Constant {
388
- value : constant_piece. to_owned ( ) . into ( ) ,
387
+ value : constant_piece. drain ( .. ) . collect :: < String > ( ) . into ( ) ,
389
388
kind : None ,
390
389
} ) ) ;
391
- constant_piece. clear ( ) ;
392
390
}
393
391
Ok ( spec_constructor)
394
392
}
@@ -418,7 +416,7 @@ impl<'a> StringParser<'a> {
418
416
}
419
417
if !content. is_empty ( ) {
420
418
values. push ( self . expr ( ExprKind :: Constant {
421
- value : mem :: take ( & mut content ) . into ( ) ,
419
+ value : content . drain ( .. ) . collect :: < String > ( ) . into ( ) ,
422
420
kind : None ,
423
421
} ) ) ;
424
422
}
0 commit comments