@@ -26,7 +26,7 @@ pub fn expand(
26
26
let #name = #value;
27
27
} ,
28
28
None => {
29
- let name = format ! ( "unit{}" , idx ) ;
29
+ let name = format ! ( "unit{idx}" ) ;
30
30
syn:: parse_quote!{
31
31
let #name = #value;
32
32
}
@@ -39,7 +39,7 @@ pub fn expand(
39
39
match field. ident . as_ref ( ) {
40
40
Some ( name) => syn:: parse_quote!( #name) ,
41
41
None => {
42
- let name = format ! ( "unit{}" , idx ) ;
42
+ let name = format ! ( "unit{idx}" ) ;
43
43
syn:: parse_quote!( #name)
44
44
}
45
45
}
@@ -119,11 +119,11 @@ pub fn expand(
119
119
let fields = iter
120
120
. enumerate ( )
121
121
. map ( |( idx, field) | -> syn:: Arm {
122
- let idx: u32 = idx. try_into ( ) . expect ( "enum tag max 32bit" ) ;
123
122
let idx = idx + 1 ; // skip zero
123
+ let idx: u32 = idx. try_into ( ) . expect ( "enum tags must not exceed 32 bits" ) ;
124
124
let name = & field. ident ;
125
125
126
- assert ! ( field. discriminant. is_none( ) , "custom discriminant unsupport " ) ;
126
+ assert ! ( field. discriminant. is_none( ) , "custom discriminant is not allowed " ) ;
127
127
assert ! ( !is_unknown( & field. attrs) , "unknown member must be first" ) ;
128
128
129
129
match & field. fields {
@@ -132,8 +132,8 @@ pub fn expand(
132
132
panic ! ( "enum member only allows one field" ) ;
133
133
}
134
134
135
- if * is_unit. get_or_insert ( false ) != false {
136
- panic ! ( "The number of fields in member must be consistent" ) ;
135
+ if * is_unit. get_or_insert ( false ) {
136
+ panic ! ( "the number of fields in member must be consistent" ) ;
137
137
}
138
138
let val_ty = & fields. unnamed [ 0 ] . ty ;
139
139
let value: syn:: Expr = match is_with ( & field. attrs ) {
@@ -149,8 +149,8 @@ pub fn expand(
149
149
}
150
150
} ,
151
151
syn:: Fields :: Unit => {
152
- if * is_unit. get_or_insert ( true ) != true {
153
- panic ! ( "The number of fields in member must be consistent" ) ;
152
+ if ! * is_unit. get_or_insert ( true ) {
153
+ panic ! ( "the number of fields in member must be consistent" ) ;
154
154
}
155
155
assert ! ( is_with( & field. attrs) . is_none( ) , "unit member is not allowed with type" ) ;
156
156
0 commit comments