Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 4 additions & 10 deletions benzina-derive/src/join/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ pub(crate) struct Join {
}

pub(super) enum NestedOrNot {
Nested(Punctuated<Transformation, Token![,]>),
Nested(Transformation),
Not(NoTransformation),
}

Expand Down Expand Up @@ -76,17 +76,14 @@ impl ToTokens for Join {
impl NestedOrNot {
fn map_type_values(&self) -> Vec<TokenStream> {
match self {
Self::Nested(nested) => nested.iter().map(Transformation::map_type).collect(),
Self::Nested(nested) => vec![nested.map_type()],
Self::Not(not) => not.map_type_values(),
}
}

fn accumulator(&self, accumulator_index: usize) -> TokenStream {
match self {
Self::Nested(nested) => nested
.iter()
.flat_map(|item| item.accumulator(Some(accumulator_index)))
.collect(),
Self::Nested(nested) => nested.accumulator(Some(accumulator_index)),
Self::Not(not) => not.accumulator(accumulator_index),
}
}
Expand All @@ -102,10 +99,7 @@ impl NestedOrNot {

fn presenter(&self, accumulator: &TokenStream) -> TokenStream {
match self {
Self::Nested(nested) => nested
.iter()
.flat_map(|item| item.presenter(accumulator))
.collect::<TokenStream>(),
Self::Nested(nested) => nested.presenter(accumulator),
Self::Not(not) => not.presenter(accumulator),
}
}
Expand Down
3 changes: 1 addition & 2 deletions benzina-derive/src/join/parse.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,7 @@ impl Parse for NestedOrNot {
let _ = input.parse::<NoTransformation>()?;
Ok(Self::Not(not))
} else {
let conversions = Punctuated::parse_terminated(input)?;
Ok(Self::Nested(conversions))
Ok(Self::Nested(input.parse::<Transformation>()?))
}
}
}
Expand Down