[][src]Macro born::nested_macro

macro_rules! nested_macro {
    ($($body:tt)*) => { ... };
}

You can make a macro that creates other macros with it.

Example

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, )+
                        }
                    };
                }
            }
        }
    };
}