Hi folks,
I can't figure out how to write this: input.parse::<Token![(]>() (for a proc macro).
I tried different escapes to escape the bracket....
Hi folks,
I can't figure out how to write this: input.parse::<Token![(]>() (for a proc macro).
I tried different escapes to escape the bracket....
Are you looking for token::Paren?
In Rust, ( and ) are never tokens by themselves — they are always kept together with their contents as a single token tree. So it’s not just that Token![(] can’t be written — a lone left parenthesis never exists, either.
I haven’t personally written any custom parsers with syn, but this looks promising: https://docs.rs/syn/2/syn/macro.parenthesized.html
Parse a set of parentheses and expose their content to subsequent parsers.
This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.