I'm trying to write a Rust procedural macro that can be applied to an impl block like this;
struct SomeStruct { }
#[my_macro]
impl SomeStruct { }
I'm using syn and quote to parse and format TokenStream
s in the macro. It looks something like this:
#[proc_macro_attribute]
pub fn my_macro(meta: TokenStream, code: TokenStream) -> TokenStream {
let input = parse_macro_input!(code as ItemImpl);
// ...
TokenStream::from(quote!(#input))
}
Is there a way to access the type name of the impl block using syn? I don't see any field in ItemImpl
that gives me that information.