Skip to main content

ctor/
priority.rs

1//! Utility macro for converting priority values to literals.
2
3/// Make a macro that zero-pads priority values to 3 digits.
4macro_rules! __make_priority_literal {
5    ($dollar:tt $(
6        ($prefix:literal $( $priority:tt )*)
7    )*) => {
8        /// Convert a priority value to a literal if 0 < N < 1000, otherwise pass through the value.
9        #[doc(hidden)]
10        #[macro_export]
11        macro_rules! __priority_to_literal {
12            $(
13                $(
14                    ($dollar n:path, $dollar a:tt = $priority ) => {
15                        $n!($a, (concat!(stringify!($prefix), stringify!($priority))));
16                    };
17                )*
18            )*
19
20            ($n:path, $a:tt=$dollar priority:tt) => {
21                $n!($a, ($dollar priority));
22            };
23        }
24    };
25}
26
27__make_priority_literal! { $
28    (00 0 1 2 3 4 5 6 7 8 9)
29    (0 10 11 12 13 14 15 16 17 18 19)
30    (0 20 21 22 23 24 25 26 27 28 29)
31    (0 30 31 32 33 34 35 36 37 38 39)
32    (0 40 41 42 43 44 45 46 47 48 49)
33    (0 50 51 52 53 54 55 56 57 58 59)
34    (0 60 61 62 63 64 65 66 67 68 69)
35    (0 70 71 72 73 74 75 76 77 78 79)
36    (0 80 81 82 83 84 85 86 87 88 89)
37    (0 90 91 92 93 94 95 96 97 98 99)
38}