@@ -19,32 +19,29 @@ pub fn derive_insertable(input: proc_macro::TokenStream) -> proc_macro::TokenStr
19
19
} ;
20
20
21
21
let name = derive_input. ident ;
22
- let fields = struct_fields_idents ( derive_input. data ) ;
23
- let fields_to_stringify = fields. iter ( ) . map ( |field| field. unraw ( ) ) ;
24
- let number_of_fields = fields. len ( ) ;
22
+ let field_idents = struct_field_idents ( derive_input. data ) ;
23
+ let field_idents_to_stringify = field_idents. iter ( ) . map ( |field| field. unraw ( ) ) ;
25
24
26
25
let table_struct = parse_table_struct ( opts. table_struct ) ;
27
26
28
- let expanded = quote ! {
27
+ quote ! {
29
28
#[ :: async_trait:: async_trait]
30
29
#[ automatically_derived]
31
- impl Insertable <#number_of_fields> for #name {
30
+ impl Insertable for #name {
32
31
type T = #table_struct;
33
32
34
33
fn columns( ) -> & ' static [ & ' static str ] {
35
- [ #( stringify!( #fields_to_stringify ) ) , * ]
34
+ [ #( stringify!( #field_idents_to_stringify ) ) , * ]
36
35
}
37
36
38
37
fn bind(
39
38
self ,
40
39
separated: & mut :: sqlx:: query_builder:: Separated <' _, ' _, :: sqlx:: Postgres , & ' static str >
41
40
) {
42
- #( separated. push_bind( self . #fields ) ; ) *
41
+ #( separated. push_bind( self . #field_idents ) ; ) *
43
42
}
44
43
}
45
- } ;
46
-
47
- expanded. into ( )
44
+ } . into ( )
48
45
}
49
46
50
47
#[ derive( FromDeriveInput , Debug ) ]
@@ -65,7 +62,7 @@ pub fn derive_changeset(input: proc_macro::TokenStream) -> proc_macro::TokenStre
65
62
} ;
66
63
67
64
let name = derive_input. ident ;
68
- let fields = struct_fields_idents ( derive_input. data ) ;
65
+ let fields = struct_field_idents ( derive_input. data ) ;
69
66
let fields_to_stringify = fields. iter ( ) . map ( |field| field. unraw ( ) ) ;
70
67
let number_of_fields = fields. len ( ) ;
71
68
@@ -138,7 +135,7 @@ fn filtered_struct_fields<T>(
138
135
}
139
136
}
140
137
141
- fn struct_fields_idents ( derive_input_data : Data ) -> Vec < Ident > {
138
+ fn struct_field_idents ( derive_input_data : Data ) -> Vec < Ident > {
142
139
filtered_struct_fields ( derive_input_data, |field| Some ( field. ident . unwrap ( ) ) )
143
140
}
144
141
0 commit comments