Closed nyurik closed 1 month ago
Far too often I find myself having a String with the needed identifier:
String
fn construct_foo_call(type_name: &str) -> TokenStream { let ident = format_ident!("{type_name}"); quote! { foo(#ident); } }
Is there a way quote! can support direct usage of strings as identifiers, e.g.
quote!
fn construct_foo_call(type_name: &str) -> TokenStream { quote! { foo(##type_name); } }
or
fn construct_foo_call(type_name: &str) -> TokenStream { quote! { foo(@type_name); } }
I would prefer not to add new special syntax in this crate for this operation. But, you're free to make your own quasiquoting macro crate that is more fully featured.
Far too often I find myself having a
String
with the needed identifier:Is there a way
quote!
can support direct usage of strings as identifiers, e.g.or