Skip to content

Commit eb7b659

Browse files
committed
fix(join): add comma at the end of tuple statement to let rust recognize a _one elemnt tuple_
1 parent 435216c commit eb7b659

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

benzina-derive/src/join/mod.rs

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,14 @@ impl Transformation {
114114
quote! { ::benzina::__private::IndexMap::<_, (#(#values),*)> }
115115
}
116116

117+
fn tuple_from_vec(vec: Vec<impl ToTokens>) -> TokenStream {
118+
if vec.is_empty() {
119+
quote! { () }
120+
} else {
121+
quote! { (#(#vec),*,) }
122+
}
123+
}
124+
117125
fn accumulator(&self, accumulator_index: Option<usize>) -> TokenStream {
118126
let accumulator_index = if let Some(accumulator_index) = accumulator_index {
119127
let accumulator_index = Index::from(accumulator_index);
@@ -140,7 +148,8 @@ impl Transformation {
140148
quote! {}
141149
};
142150

143-
let or_insert = self.or_insert(&tuple_index_overwrites);
151+
let or_insert_tokens =
152+
Transformation::tuple_from_vec(self.or_insert(&tuple_index_overwrites));
144153
let accumulator = self
145154
.entries
146155
.iter()
@@ -157,7 +166,7 @@ impl Transformation {
157166
#wrapper {
158167
let mut accumulator = ::benzina::__private::indexmap::map::Entry::or_insert(
159168
::benzina::__private::IndexMap::entry(&mut #accumulator_index, #id),
160-
(#(#or_insert),*)
169+
#or_insert_tokens
161170
);
162171
#(#accumulator)*
163172
}

0 commit comments

Comments
 (0)