Can't reasonably handle a metavariable with an optional argument:
I'm trying to replicate the derive_builder
functionality where you can say #[builder(setter(skip))]
as short for #[builder(setter(skip=true))]
.
I've written this blob:
${define T_B_SETTER_SKIP
${if all(tmeta(builder(setter(skip))),
approx_equal({${tmeta(builder(setter(skip)))}}, {})) { // (1)
true
} else if tmeta(builder(setter(skip))) {
${tmeta(builder(setter(skip))) as tokens}
} else {
false
}}
}
But that doesn't actually accept #[builder(setter(skip))]
: the first expansion (marked with (1)
) fails because there is no value for skip
.
Possible solution:
- Split the
Xmeta
condition in toXmeta_present
,Xmeta_empty
, andXmeta_has_value
. - Add a new
Xmeta
expansion decorator that accepts empty conditions, as in:${Xmeta(foo) empty_ok}
. This would probably need to interact with anything we do for #40.