desired macro output
#[derive(Debug, Hash, Eq, PartialEq, Copy, Clone)]
pub struct Animal_Id_Cat {}
#[derive(Debug, Hash, Eq, PartialEq, Copy, Clone)]
pub struct Animal_Id_Dog {}
#[derive(Debug, Hash, Eq, PartialEq, Copy, Clone)]
pub struct Animal_Id_Bird {}
pub struct Animal_Strut {
cat: Animal_Id_Cat,
dog: Animal_Id_Dog,
bird: Animal_Id_Bird,
}
pub enum Animal_Enum {
Cat(Animal_Id_Cat),
Dog(Animal_Id_Dog),
Bird(Animal_Id_Bird),
}
how I want to call the macro
make_id_enum_struct! {
Animal_Struct Animal_Enum
#[derive(Debug, Hash, Eq, PartialEq, Copy, Clone)]
(cat, Cat, Animal_Id_Cat);
(dog, Dog, Animal_Id_Dog);
(bird, Bird, Animal_Id_Bird);
}
what I have so far
#[macro_export]
macro_rules! make_id_enum_struct {
{
$struct_name:ident $enum_name:ident
$( #[$meta:meta] )*
$( ( $a:tt, $b:tt, $c:tt ); )*
} => {
$( #[$meta] )*
$( pub struct $c {} )*
pub struct $struct_name {
$( $a : $c ),*
}
pub enum $enum_name {
$( $b ( $c ) ),*
}
}
}
what is broken
how do I repeat the #derive[...]
part FOR EVERY STRUCT decl ?
This is the problem I am running into. I have captured the meta tags for the struct via repetition. Now I want to repeat it ONCE PER STRUCT.
Thanks!