File tree Expand file tree Collapse file tree 2 files changed +22
-6
lines changed Expand file tree Collapse file tree 2 files changed +22
-6
lines changed Original file line number Diff line number Diff line change
1
+ use syn:: parse:: { Parse , ParseStream , Result } ;
2
+
3
+ pub struct Args {
4
+ pub local : bool
5
+ }
6
+
7
+ mod kw {
8
+ syn:: custom_keyword!( local) ;
9
+ }
10
+
11
+ impl Parse for Args {
12
+ fn parse ( input : ParseStream ) -> Result < Self > {
13
+ let local: Option < kw:: local > = input. parse ( ) ?;
14
+ Ok ( Args {
15
+ local : local. is_some ( ) ,
16
+ } )
17
+ }
18
+ }
Original file line number Diff line number Diff line change 299
299
300
300
extern crate proc_macro;
301
301
302
+ mod args;
302
303
mod expand;
303
304
mod lifetime;
304
305
mod parse;
305
306
mod receiver;
306
307
308
+ use crate :: args:: Args ;
307
309
use crate :: expand:: expand;
308
310
use crate :: parse:: Item ;
309
311
use proc_macro:: TokenStream ;
310
312
use quote:: quote;
311
313
use syn:: parse_macro_input;
312
314
313
- mod kw {
314
- syn:: custom_keyword!( local) ;
315
- }
316
-
317
315
#[ proc_macro_attribute]
318
316
pub fn async_trait ( args : TokenStream , input : TokenStream ) -> TokenStream {
319
- let local = parse_macro_input ! ( args as Option <kw :: local> ) . is_some ( ) ;
317
+ let args = parse_macro_input ! ( args as Args ) ;
320
318
let mut item = parse_macro_input ! ( input as Item ) ;
321
- expand ( & mut item, local) ;
319
+ expand ( & mut item, args . local ) ;
322
320
TokenStream :: from ( quote ! ( #item) )
323
321
}
You can’t perform that action at this time.
0 commit comments