Closed IbrahimFadel closed 2 years ago
I'm trying to use macros inside of quote, and i need the identifier i pass to my macro to be an operator
let ident = format_ident!("-"); quote! { foo!(#ident) }
This panics with '"-" is not a valid Ident'. It makes sense since it's not a valid identifier, but is there some other way i could accomplish this?
'"-" is not a valid Ident'
I can avoid the panic by just doing let ident = format!("-");, but then quote generates foo!("-") which is not what i want. I want foo!(-).
let ident = format!("-");
quote
foo!("-")
foo!(-)
I could work around this by changing my macro to accept foo!("-"), but i would rather not have to do that.
If quote is intentionally built this way, then it's okay. But otherwise, it would be nice to have this as a feature.
Hi @IbrahimFadel, sorry that no one was able to provide guidance here. If this is still an issue, you could try taking this question to any of the resources shown in https://www.rust-lang.org/community.
I'm trying to use macros inside of quote, and i need the identifier i pass to my macro to be an operator
This panics with
'"-" is not a valid Ident'
. It makes sense since it's not a valid identifier, but is there some other way i could accomplish this?I can avoid the panic by just doing
let ident = format!("-");
, but thenquote
generatesfoo!("-")
which is not what i want. I wantfoo!(-)
.I could work around this by changing my macro to accept
foo!("-")
, but i would rather not have to do that.If
quote
is intentionally built this way, then it's okay. But otherwise, it would be nice to have this as a feature.