I have written procedural macros of the following form:
#[derive(ABC)]
pub struct A { ... }
#[derive(ABC)]
pub enum B { ... }
i.e. the macro acts upon Structs/Enums, and it generates impls.
Now, I want to something a bit different, where I call the macro via:
#[derive(DEF)]
pub trait SomeTrait { ... }
and have it auto generate the following:
pub struct A { ... };
pub struct B { ... };
impl SomeTrait for A { ... }
impl SomeTrait for B { ... }
I.e. here:
-
we call the macro on a TRAIT (not Struct of Enum)
-
the procedural macro generates (a) Structs and (b)
impl SomeTrait for Struct ...
s , i.e. implementations for the structs.
====
Is this do-able via procedural macros in Rust? If so, what should I be looking up?