@@ -9,11 +9,9 @@ use crate::{
9
9
} ;
10
10
use proc_macro2:: TokenStream ;
11
11
use quote:: { format_ident, quote} ;
12
+ use syn:: parse:: { Parse , ParseStream } ;
13
+ use syn:: punctuated:: Punctuated ;
12
14
use syn:: { ext:: IdentExt , spanned:: Spanned , Result } ;
13
- use syn:: {
14
- parse:: { Parse , ParseStream } ,
15
- token:: Comma ,
16
- } ;
17
15
18
16
mod signature;
19
17
@@ -96,24 +94,8 @@ impl Parse for PyFunctionOptions {
96
94
fn parse ( input : ParseStream < ' _ > ) -> Result < Self > {
97
95
let mut options = PyFunctionOptions :: default ( ) ;
98
96
99
- while !input. is_empty ( ) {
100
- let lookahead = input. lookahead1 ( ) ;
101
- if lookahead. peek ( attributes:: kw:: name)
102
- || lookahead. peek ( attributes:: kw:: pass_module)
103
- || lookahead. peek ( attributes:: kw:: signature)
104
- || lookahead. peek ( attributes:: kw:: text_signature)
105
- {
106
- options. add_attributes ( std:: iter:: once ( input. parse ( ) ?) ) ?;
107
- if !input. is_empty ( ) {
108
- let _: Comma = input. parse ( ) ?;
109
- }
110
- } else if lookahead. peek ( syn:: Token ![ crate ] ) {
111
- // TODO needs duplicate check?
112
- options. krate = Some ( input. parse ( ) ?) ;
113
- } else {
114
- return Err ( lookahead. error ( ) ) ;
115
- }
116
- }
97
+ let attrs = Punctuated :: < PyFunctionOption , syn:: Token ![ , ] > :: parse_terminated ( input) ?;
98
+ options. add_attributes ( attrs) ?;
117
99
118
100
Ok ( options)
119
101
}
0 commit comments