File tree Expand file tree Collapse file tree 4 files changed +28
-44
lines changed Expand file tree Collapse file tree 4 files changed +28
-44
lines changed Original file line number Diff line number Diff line change @@ -16,7 +16,7 @@ edition = "2018"
16
16
[dependencies ]
17
17
proc-macro2 = " 1"
18
18
quote = " 1"
19
- syn = " 1 "
19
+ syn = " 2 "
20
20
21
21
[dev-dependencies ]
22
22
num = " 0.3"
Original file line number Diff line number Diff line change @@ -170,16 +170,22 @@ impl NumTraits {
170
170
// retrieve its value, and use it to create an `Ident` to be used
171
171
// to import the `num_traits` crate.
172
172
for attr in & ast. attrs {
173
- if let Ok ( syn:: Meta :: NameValue ( mnv) ) = attr. parse_meta ( ) {
174
- if mnv. path . is_ident ( "num_traits" ) {
175
- if let syn:: Lit :: Str ( lit_str) = mnv. lit {
176
- return NumTraits {
177
- import : syn:: Ident :: new ( & lit_str. value ( ) , lit_str. span ( ) ) ,
178
- explicit : true ,
179
- } ;
180
- } else {
181
- panic ! ( "#[num_traits] attribute value must be a str" ) ;
182
- }
173
+ if attr. path ( ) . is_ident ( "num_traits" ) {
174
+ if let Ok ( syn:: MetaNameValue {
175
+ value :
176
+ syn:: Expr :: Lit ( syn:: ExprLit {
177
+ lit : syn:: Lit :: Str ( ref lit_str) ,
178
+ ..
179
+ } ) ,
180
+ ..
181
+ } ) = attr. meta . require_name_value ( )
182
+ {
183
+ return NumTraits {
184
+ import : syn:: Ident :: new ( & lit_str. value ( ) , lit_str. span ( ) ) ,
185
+ explicit : true ,
186
+ } ;
187
+ } else {
188
+ panic ! ( "#[num_traits] attribute value must be a str" ) ;
183
189
}
184
190
}
185
191
}
@@ -954,5 +960,3 @@ pub fn float(input: TokenStream) -> TokenStream {
954
960
955
961
import. wrap ( "Float" , & name, impl_) . into ( )
956
962
}
957
-
958
- mod test;
Load Diff This file was deleted.
Original file line number Diff line number Diff line change
1
+ macro_rules! get_an_isize {
2
+ ( ) => {
3
+ 0_isize
4
+ } ;
5
+ }
6
+
7
+ #[ derive( num_derive:: FromPrimitive ) ]
8
+ pub enum CLikeEnum {
9
+ VarA = get_an_isize ! ( ) ,
10
+ VarB = 2 ,
11
+ }
You can’t perform that action at this time.
0 commit comments