Skip to content

Commit 38ba175

Browse files
fix(join!)!: parsing NestedOrNot::Nested by removing needless Punctuated
My initial implementation of `NestedOrNot` wrapped `Transformation` with `Punctuated`, but `Transformation` itself then expects items to be punctuated. This messed with the parser and made it think the field name was the quantity.
1 parent 1928002 commit 38ba175

File tree

2 files changed

+5
-12
lines changed

2 files changed

+5
-12
lines changed

benzina-derive/src/join/mod.rs

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ pub(crate) struct Join {
1919
}
2020

2121
pub(super) enum NestedOrNot {
22-
Nested(Punctuated<Transformation, Token![,]>),
22+
Nested(Transformation),
2323
Not(NoTransformation),
2424
}
2525

@@ -76,17 +76,14 @@ impl ToTokens for Join {
7676
impl NestedOrNot {
7777
fn map_type_values(&self) -> Vec<TokenStream> {
7878
match self {
79-
Self::Nested(nested) => nested.iter().map(Transformation::map_type).collect(),
79+
Self::Nested(nested) => vec![nested.map_type()],
8080
Self::Not(not) => not.map_type_values(),
8181
}
8282
}
8383

8484
fn accumulator(&self, accumulator_index: usize) -> TokenStream {
8585
match self {
86-
Self::Nested(nested) => nested
87-
.iter()
88-
.flat_map(|item| item.accumulator(Some(accumulator_index)))
89-
.collect(),
86+
Self::Nested(nested) => nested.accumulator(Some(accumulator_index)),
9087
Self::Not(not) => not.accumulator(accumulator_index),
9188
}
9289
}
@@ -102,10 +99,7 @@ impl NestedOrNot {
10299

103100
fn presenter(&self, accumulator: &TokenStream) -> TokenStream {
104101
match self {
105-
Self::Nested(nested) => nested
106-
.iter()
107-
.flat_map(|item| item.presenter(accumulator))
108-
.collect::<TokenStream>(),
102+
Self::Nested(nested) => nested.presenter(accumulator),
109103
Self::Not(not) => not.presenter(accumulator),
110104
}
111105
}

benzina-derive/src/join/parse.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,7 @@ impl Parse for NestedOrNot {
2727
let _ = input.parse::<NoTransformation>()?;
2828
Ok(Self::Not(not))
2929
} else {
30-
let conversions = Punctuated::parse_terminated(input)?;
31-
Ok(Self::Nested(conversions))
30+
Ok(Self::Nested(input.parse::<Transformation>()?))
3231
}
3332
}
3433
}

0 commit comments

Comments
 (0)