konst/macros/
declare_generic_const.rs

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
macro_rules! declare_generic_const {
    (
        $(
            $(#[$meta:meta])*
            for[$($gen_param:tt)*]
            $vis:vis const $name:ident [$($lt:lifetime,)* $($ty:ident),* $(; $($const:ident),*)? ]
            :$ret:ty = $value:expr;
        )*
    ) => {
        $(
            $(#[$meta])*
            #[allow(non_camel_case_types)]
            $vis struct $name<$($gen_param)*>(
                core::marker::PhantomData<(
                    $( core::marker::PhantomData<&$lt ()>, )*
                    $( core::marker::PhantomData<$ty>, )*
                )>
            );

            impl<$($gen_param)*> $name<$($lt,)* $($ty,)* $($($const,)*)? > {
                /// The value that this constructs.
                $vis const V: $ret = $value;
            }
        )*
    };
}