I’m trying to write a proc_macro that automatically implement a trait for a struct. The trait is as follows
<code>trait StructName {
fn name(&self) -> &'static str;
}
</code>
<code>trait StructName {
fn name(&self) -> &'static str;
}
</code>
trait StructName {
fn name(&self) -> &'static str;
}
However, I found it hard to escape quote mark in the quote macro, for example, the following code is not working
<code>let self_ty: Box<syn::Type> = ...;
quote!(
impl StructName for #self_ty {
fn name(&self) -> &'static str {
"#self_ty"
}
}
)
</code>
<code>let self_ty: Box<syn::Type> = ...;
quote!(
impl StructName for #self_ty {
fn name(&self) -> &'static str {
"#self_ty"
}
}
)
</code>
let self_ty: Box<syn::Type> = ...;
quote!(
impl StructName for #self_ty {
fn name(&self) -> &'static str {
"#self_ty"
}
}
)
How to escape quote mark in the quote macro?
2