I'm trying to understand how Rust macro captures work and am looking at the nom parser library.
Location nom/src/bytes.rs declares macro tag!
which captures with ($i:expr, $tag: expr)
.
However throughout the places where tag!
is used it is used with only one argument, i.e. tag!("+")
.
Example: nom-lua52/op.rs. I've read tutorials about macros however this construct seems to be special.
It seems like the input $i
is somehow implicit?
The trick is that the tag!()
macro call is inside the value!
macro, which will match against tag!
and pass it an additional parameter. This is described in the file implementing tag!
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With