You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I’m tinkering with writing a transpiler and am currently in the lexing stage. In my Token enum I have the following variant: CurlyClose. I’d like to implement the Display trait for Token using strum.
What I currently have:
#[derive(Debug,Clone, strum_macros::Display)]pubenumToken{// Other tokens …/// An opening curly brace; `{`.#[strum(to_string = "{")]CurlyOpen,/// A closing curly brace; `}`.#[strum(to_string = "}")]// <—- “Bracket closed without previous opened bracket”CurlyClose,// Other tokens …}
The #[strum(to_string = "}")] macro is throwing a Bracket closed without previous opened bracket compiler error. When I try to escape the closing curly brace the macro panics with proc-macro panicked: unexpected byte '}' after \ character in string literal.
Am I doing something wrong? Other braces such as {[]( and ) work fine.
The text was updated successfully, but these errors were encountered:
Somfic
changed the title
Bracket closed without previous opened bracket
Using #[strum(to_string = "}")] results in macro error
Jun 8, 2024
Hi!
I’m tinkering with writing a transpiler and am currently in the lexing stage. In my
Token
enum I have the following variant:CurlyClose
. I’d like to implement theDisplay
trait forToken
using strum.What I currently have:
The
#[strum(to_string = "}")]
macro is throwing aBracket closed without previous opened bracket
compiler error. When I try to escape the closing curly brace the macro panics withproc-macro panicked: unexpected byte '}' after \ character in string literal
.Am I doing something wrong? Other braces such as
{
[
]
(
and)
work fine.The text was updated successfully, but these errors were encountered: