binreader_internal_macros/
helpers.rs

1#[macro_export]
2macro_rules! make_add_macro {
3    (
4        ($d:tt)
5        name: $name_:ident;
6        type: $type_:path;
7        body: {$($body:item)+}
8    ) => {
9        #[macro_export]
10        macro_rules! $name_ {
11            ($type:path) => {
12                impl $type_ for $type { $($body)+ }
13            };
14
15            ($type:path, $d($lifetimes:lifetime),+ $d($generics:ident),*) => {
16                    impl<$d($lifetimes,)+ $d($generics,)*> $type_ for $type { $($body)+ }
17            }
18        }
19    };
20    (
21        name: $name:ident;
22        type: $type:path;
23        body: {$($body:item)+}
24    ) => {
25        make_add_macro! {
26            ($)
27            name: $name;
28            type: $type;
29            body: { $($body)+ }
30        }
31    }
32}