File tree Expand file tree Collapse file tree 2 files changed +12
-7
lines changed Expand file tree Collapse file tree 2 files changed +12
-7
lines changed Original file line number Diff line number Diff line change @@ -2,21 +2,26 @@ use proc_macro2::TokenStream;
22use quote:: quote;
33use syn:: { DeriveInput , Expr } ;
44
5- pub ( crate ) fn derive_struct_parameters ( input : DeriveInput ) -> syn:: Result < TokenStream > {
5+ pub ( crate ) fn derive_structured_parameters ( input : DeriveInput ) -> syn:: Result < TokenStream > {
66 let ident = input. ident ;
77
8- let fields = match input. data {
9- syn:: Data :: Struct ( ref s) => & s . fields ,
8+ match input. data {
9+ syn:: Data :: Struct ( ref s) => derive_structured_parameters_struct ( ident , s ) ,
1010 _ => {
1111 return syn:: Result :: Err ( syn:: Error :: new_spanned (
1212 ident,
1313 "StructuredParameters trait can only be derived for structs" ,
1414 ) ) ;
1515 }
16- } ;
16+ }
17+ }
18+ pub ( crate ) fn derive_structured_parameters_struct (
19+ ident : proc_macro2:: Ident ,
20+ struct_ : & syn:: DataStruct ,
21+ ) -> syn:: Result < TokenStream > {
22+ let fields = & struct_. fields ;
1723
1824 let field_types: Vec < _ > = fields. iter ( ) . map ( |f| & f. ty ) . collect ( ) ;
19-
2025 let mut args = Vec :: new ( ) ;
2126 for f in fields {
2227 let ident = f. ident . as_ref ( ) . unwrap ( ) ;
Original file line number Diff line number Diff line change @@ -3,9 +3,9 @@ use proc_macro::TokenStream;
33use syn:: { parse_macro_input, DeriveInput } ;
44
55#[ proc_macro_derive( StructuredParameters , attributes( param) ) ]
6- pub fn derive_struct_parameters ( input : TokenStream ) -> TokenStream {
6+ pub fn derive_structured_parameters ( input : TokenStream ) -> TokenStream {
77 let input = parse_macro_input ! ( input as DeriveInput ) ;
8- r#impl:: derive_struct_parameters ( input)
8+ r#impl:: derive_structured_parameters ( input)
99 . unwrap_or_else ( |e| e. to_compile_error ( ) )
1010 . into ( )
1111}
You can’t perform that action at this time.
0 commit comments