@@ -110,7 +110,7 @@ fn test_struct_body_take() {
110
110
assert_eq ! ( ident, "Foo" ) ;
111
111
let body = StructBody :: take ( stream) . unwrap ( ) ;
112
112
if let Some ( Fields :: Struct ( v) ) = body. fields {
113
- assert ! ( v. len ( ) == 0 ) ;
113
+ assert ! ( v. is_empty ( ) ) ;
114
114
} else {
115
115
panic ! ( "wrong fields {:?}" , body. fields) ;
116
116
}
@@ -121,7 +121,7 @@ fn test_struct_body_take() {
121
121
assert_eq ! ( ident, "Foo" ) ;
122
122
let body = StructBody :: take ( stream) . unwrap ( ) ;
123
123
if let Some ( Fields :: Tuple ( v) ) = body. fields {
124
- assert ! ( v. len ( ) == 0 ) ;
124
+ assert ! ( v. is_empty ( ) ) ;
125
125
} else {
126
126
panic ! ( "wrong fields {:?}" , body. fields) ;
127
127
}
@@ -297,9 +297,7 @@ fn test_enum_body_take() {
297
297
let fields = body. variants [ 1 ] . fields . as_ref ( ) . unwrap ( ) ;
298
298
assert_eq ! ( fields. len( ) , 1 ) ;
299
299
assert_eq ! ( fields. names( ) . len( ) , 1 ) ;
300
- assert ! (
301
- matches!( fields. names( ) [ 0 ] , IdentOrIndex :: Ident { ident, .. } if ident. to_string( ) == "a" )
302
- ) ;
300
+ assert ! ( matches!( & fields. names( ) [ 0 ] , IdentOrIndex :: Ident { ident, .. } if * ident == "a" ) ) ;
303
301
assert_eq ! ( body. variants[ 1 ] . get_integer( ) , 2 ) ;
304
302
305
303
let stream = & mut token_stream ( "enum Foo { Round(), Curly{}, Without }" ) ;
@@ -395,14 +393,14 @@ impl Fields {
395
393
. map ( |( index, field) | IdentOrIndex :: Index {
396
394
index,
397
395
span : field. span ( ) ,
398
- attributes : & field. attributes ,
396
+ attributes : field. attributes . clone ( ) ,
399
397
} )
400
398
. collect ( ) ,
401
399
Self :: Struct ( fields) => fields
402
400
. iter ( )
403
401
. map ( |( ident, field) | IdentOrIndex :: Ident {
404
- ident,
405
- attributes : & field. attributes ,
402
+ ident : ident . clone ( ) ,
403
+ attributes : field. attributes . clone ( ) ,
406
404
} )
407
405
. collect ( ) ,
408
406
} ;
@@ -552,14 +550,14 @@ impl UnnamedField {
552
550
/// a: u32, // will be IdentOrIndex::Ident { ident: "a", .. }
553
551
/// },
554
552
/// }
555
- #[ derive( Debug ) ]
556
- pub enum IdentOrIndex < ' a > {
553
+ #[ derive( Debug , Clone ) ]
554
+ pub enum IdentOrIndex {
557
555
/// The variant is a named field
558
556
Ident {
559
557
/// The name of the field
560
- ident : & ' a Ident ,
558
+ ident : Ident ,
561
559
/// The attributes of the field
562
- attributes : & ' a Vec < Attribute > ,
560
+ attributes : Vec < Attribute > ,
563
561
} ,
564
562
/// The variant is an unnamed field
565
563
Index {
@@ -568,15 +566,15 @@ pub enum IdentOrIndex<'a> {
568
566
/// The span of the field type
569
567
span : Span ,
570
568
/// The attributes of this field
571
- attributes : & ' a Vec < Attribute > ,
569
+ attributes : Vec < Attribute > ,
572
570
} ,
573
571
}
574
572
575
- impl < ' a > IdentOrIndex < ' a > {
573
+ impl IdentOrIndex {
576
574
/// Get the ident. Will panic if this is an `IdentOrIndex::Index`
577
- pub fn unwrap_ident ( & self ) -> & ' a Ident {
575
+ pub fn unwrap_ident ( & self ) -> Ident {
578
576
match self {
579
- Self :: Ident { ident, .. } => ident,
577
+ Self :: Ident { ident, .. } => ident. clone ( ) ,
580
578
x => panic ! ( "Expected ident, found {:?}" , x) ,
581
579
}
582
580
}
@@ -611,7 +609,7 @@ impl<'a> IdentOrIndex<'a> {
611
609
}
612
610
}
613
611
614
- impl std:: fmt:: Display for IdentOrIndex < ' _ > {
612
+ impl std:: fmt:: Display for IdentOrIndex {
615
613
fn fmt ( & self , fmt : & mut std:: fmt:: Formatter ) -> std:: fmt:: Result {
616
614
match self {
617
615
IdentOrIndex :: Ident { ident, .. } => write ! ( fmt, "{}" , ident) ,
0 commit comments