Closed NovaliX-Dev closed 3 days ago
This is already supported well enough by interpolating iterators.
let val = option.iter();
quote!(bla #(_ => #val)* bla)
Thank you for your quick response ! But the problem still remains : we create a temp variable, something i was trying to avoid. (Sorry I've didn't mentioned that goal directly).
This issue is kinda similar to #20, but it propose something more featured and more general.
The macros in rust have a syntax for tokens with zero or one ocurences :
$(<something>)?
.I would like to have this implemented for the quote macro as well, and one of the possible application for this syntax is for the optioned tokens.
Here is an example (assembled in like 5 minutes) of how i'm seeing things :
For the moment I'm implementing this in the manual way, by storing the conditionally produced tokens an intermediate variable and then using that variable in a final quote macro:
The end goal would be to remove the temp variable completely.
What do you all think about this proposal ?