#[macro_export]
macro_rules! public_struct {
(pub struct $commonstruct:ident { $( $commonfieldpub:vis $commonfield:ident: $commonty:ty ),+ $(,)* }) => {
nested_macro! {
($s:tt) => {
macro_rules! $commonstruct {
() => {
pub struct $commonstruct {
$( $commonfieldpub $commonfield: $commonty, )+
}
};
(#[derive($s($arg:tt)+)]) => {
#[derive($s($arg)+)]
pub struct $commonstruct {
$( $commonfieldpub $commonfield: $commonty, )+
}
};
(pub struct $name:ident { $s( $pub:vis $field:ident: $ty:ty ),+ $s(,)* }) => {
pub struct $name {
$( $commonfieldpub $commonfield: $commonty, )+
$s( $pub $field: $ty ),+
}
};
(#[derive($s($arg:tt)+)] pub struct $name:ident { $s( $pub:vis $field:ident: $ty:ty ),+ $s(,)* }) => {
#[derive($s($arg)+)]
pub struct $name {
$( $commonfieldpub $commonfield: $commonty, )+
$s( $pub $field: $ty ),+
}
};
(pub struct $name:ident) => {
pub struct $name {
$( $commonfieldpub $commonfield: $commonty, )+
}
};
(#[derive($s($arg:tt)+)] pub struct $name:ident) => {
#[derive($s($arg)+)]
pub struct $name {
$( $commonfieldpub $commonfield: $commonty, )+
}
};
}
}
}
};
}