|
1 | | -macro_rules! declare_types { |
2 | | - ($(<$lt:lifetime>)? |
3 | | - $(derive($($Der:ident),*),)? |
4 | | - str = $s:ty, |
5 | | - List = $List:ident<_> |
6 | | - ) => { |
7 | | - /// A module of definitions. |
8 | | - $(#[derive($($Der),*)])? |
9 | | - pub struct Module<$($lt)?>($List<($s, Binding<$($lt)?>)>); |
10 | | - |
11 | | - /// A definition bound in a module, with metadata. |
12 | | - $(#[derive($($Der),*)])? |
13 | | - pub struct Binding<$($lt)?> { |
14 | | - /// The bound definition. |
15 | | - pub def: Def<$($lt)?>, |
16 | | - /// A deprecation message for the definition, if it is deprecated. |
17 | | - pub deprecation: Option<$s>, |
18 | | - } |
19 | | - |
20 | | - impl<$($lt)?> Binding<$($lt)?> { |
21 | | - /// Create a new bound definition. |
22 | | - pub const fn new(definition: Def<$($lt)?>) -> Self { |
23 | | - Self { def: definition, deprecation: None } |
24 | | - } |
25 | | - } |
26 | | - |
27 | | - /// A definition in a module. |
28 | | - $(#[derive($($Der),*)])? |
29 | | - pub enum Def<$($lt)?> { |
30 | | - /// A symbol, potentially with modifiers. |
31 | | - Symbol(Symbol<$($lt)?>), |
32 | | - /// A nested module. |
33 | | - Module(Module<$($lt)?>), |
34 | | - } |
35 | | - |
36 | | - /// A symbol, either a leaf or with modifiers. |
37 | | - $(#[derive($($Der),*)])? |
38 | | - pub enum Symbol<$($lt)?> { |
39 | | - /// A symbol without modifiers. |
40 | | - Single(char), |
41 | | - /// A symbol with named modifiers. |
42 | | - /// The symbol defaults to its first variant. |
43 | | - Multi($List<(ModifierSet<$s>, char)>), |
44 | | - } |
45 | | - }; |
46 | | -} |
47 | | - |
48 | 1 | use std::ops::Deref; |
49 | 2 |
|
50 | | -pub(crate) use declare_types; |
51 | | - |
52 | 3 | /// A set of modifiers. |
53 | 4 | #[derive(Debug, Copy, Clone)] |
54 | 5 | // note: the visibility needs to be `pub(crate)`, |
|
0 commit comments