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"
1616[dependencies ]
1717proc-macro2 = " 1"
1818quote = " 1"
19- syn = " 1 "
19+ syn = " 2 "
2020
2121[dev-dependencies ]
2222num = " 0.3"
Original file line number Diff line number Diff line change @@ -170,16 +170,22 @@ impl NumTraits {
170170 // retrieve its value, and use it to create an `Ident` to be used
171171 // to import the `num_traits` crate.
172172 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" ) ;
183189 }
184190 }
185191 }
@@ -954,5 +960,3 @@ pub fn float(input: TokenStream) -> TokenStream {
954960
955961 import. wrap ( "Float" , & name, impl_) . into ( )
956962}
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