Hi,
Just something that has been tripping me up:
After reading
https://doc.rust-lang.org/reference/macros-by-example.html#repetitions, I may have overlooked it but for this expression:
($($t: expr),*)=>{
it is not written that the last comma is optional.
When one reads it, one could expect the comma to be required, even for the last item in the list.
Instead ($($t: expr,)*)=>{
does require it. Yes a last optional comma in the input can be handled with ($($t: expr),*$(,)?)=>{
.
But I think it would be clearer to write that the macro system implicitly lifts the requirement for the last separator. Maybe it's in the doc and I didn't see it. But it should be made clearer.
So we would have here:
In both the matcher and transcriber, repetitions are indicated by placing the tokens to be repeated inside
$(
…)
, followed by a repetition operator, optionally with a separator token between.Note that the compiler lifts the requirement for the last separator: it must not appear in the input. If you need it, put the separator in
$(
…)
.
or something of the like; this part need to be clearer.