Unfortunately Rust lacks variadic generics, so Xilem tuples cannot be longer than 10 children. This is solved by recursively breaking up a tuple into chunks of 10, until there is no tuple with a size greater than 10. This will be a lot less necessary once a string merging pass is added (merge consecutive strings into each other).
RAWT2FQSTIP6EWFQXMAESASEM6AIFCV4PDO6TRUN6EAFVP3526YQC
}
}
// Xilem only supports tuples of max length 10, so split up inlines into nested tuples until it fits
fn split_tuple(expressions: Vec<syn::Expr>) -> Vec<syn::Expr> {
if expressions.len() <= MAX_TUPLE_LEN {
return expressions;
}
let mut elements: Vec<syn::Expr> = Vec::new();
for expression_chunk in expressions.chunks(MAX_TUPLE_LEN) {
let expression_group: Vec<syn::Expr> = expression_chunk.to_vec();
elements.push(syn::Expr::Tuple(syn::ExprTuple {
attrs: Vec::new(),
paren_token: syn::token::Paren::default(),
elems: Punctuated::from_iter(expression_group.into_iter()),
}))
}
// May need to recursively nest inside tuples
if elements.len() > MAX_TUPLE_LEN {
elements = split_tuple(elements);
syn::Expr::Tuple(syn::ExprTuple {
attrs: Vec::new(),
paren_token: syn::token::Paren::default(),
elems: Punctuated::from_iter(expressions),
})
let tuples = split_tuple(expressions);
match &tuples[..] {
[single] => single.to_owned(),
_ => syn::Expr::Tuple(syn::ExprTuple {
attrs: Vec::new(),
paren_token: syn::token::Paren::default(),
elems: Punctuated::from_iter(tuples.into_iter()),
}),
}