I want to expand a token to a string. For example, I have this macro:
macro String {
rule {
$x
} => {
"$x"
}
}
I would expect String 1
to expand to "1"
, however it expands to just 1;
How can I accomplish this?
EDIT: This seems imposible to do with a declarative approach, but should be possible with an imperative approach (see this comment):
macro String {
case {_ $x } => {
return #{"$x"}
}
}
But that still expands with quotes.