File tree Expand file tree Collapse file tree 2 files changed +12
-2
lines changed
Expand file tree Collapse file tree 2 files changed +12
-2
lines changed Original file line number Diff line number Diff line change @@ -4,6 +4,8 @@ use proc_macro2::{Span, TokenStream};
44use quote:: { ToTokens , quote} ;
55use syn:: { Ident , Index , Token , punctuated:: Punctuated } ;
66
7+ use crate :: join:: utils:: tuple_from_vec;
8+
79use self :: {
810 quantity:: Quantity ,
911 utils:: { Identifiable , NewIndexMap } ,
@@ -140,7 +142,7 @@ impl Transformation {
140142 quote ! { }
141143 } ;
142144
143- let or_insert = self . or_insert ( & tuple_index_overwrites) ;
145+ let or_insert_tokens = tuple_from_vec ( & self . or_insert ( & tuple_index_overwrites) ) ;
144146 let accumulator = self
145147 . entries
146148 . iter ( )
@@ -157,7 +159,7 @@ impl Transformation {
157159 #wrapper {
158160 let mut accumulator = :: benzina:: __private:: indexmap:: map:: Entry :: or_insert(
159161 :: benzina:: __private:: IndexMap :: entry( & mut #accumulator_index, #id) ,
160- ( # ( #or_insert ) , * )
162+ #or_insert_tokens
161163 ) ;
162164 #( #accumulator) *
163165 }
Original file line number Diff line number Diff line change @@ -25,3 +25,11 @@ impl<T: ToTokens> ToTokens for Identifiable<T> {
2525 } ) ;
2626 }
2727}
28+
29+ pub ( super ) fn tuple_from_vec ( vec : & [ impl ToTokens ] ) -> TokenStream {
30+ if vec. is_empty ( ) {
31+ quote ! { ( ) }
32+ } else {
33+ quote ! { ( #( #vec) , * , ) }
34+ }
35+ }
You can’t perform that action at this time.
0 commit comments