Skip to content

Commit 34edb09

Browse files
committed
Remove the macro
1 parent a5cbb19 commit 34edb09

File tree

3 files changed

+57
-60
lines changed

3 files changed

+57
-60
lines changed

build.rs

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,8 @@ type StrResult<T> = Result<T, String>;
88
#[path = "src/shared.rs"]
99
mod shared;
1010

11-
self::shared::declare_types! {
12-
<'a>
13-
str = &'a str,
14-
List = Vec<_>
15-
}
11+
/// A module of definitions.
12+
struct Module<'a>(Vec<(&'a str, Binding<'a>)>);
1613

1714
impl<'a> Module<'a> {
1815
fn new(mut list: Vec<(&'a str, Binding<'a>)>) -> Self {
@@ -21,6 +18,24 @@ impl<'a> Module<'a> {
2118
}
2219
}
2320

21+
/// A definition bound in a module, with metadata.
22+
struct Binding<'a> {
23+
def: Def<'a>,
24+
deprecation: Option<&'a str>,
25+
}
26+
27+
/// A definition in a module.
28+
enum Def<'a> {
29+
Symbol(Symbol<'a>),
30+
Module(Module<'a>),
31+
}
32+
33+
/// A symbol, either a leaf or with modifiers.
34+
enum Symbol<'a> {
35+
Single(char),
36+
Multi(Vec<(ModifierSet<&'a str>, char)>),
37+
}
38+
2439
/// A single line during parsing.
2540
#[derive(Debug, Copy, Clone)]
2641
enum Line<'a> {

src/lib.rs

Lines changed: 37 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,9 @@ pub use self::shared::ModifierSet;
1212

1313
mod shared;
1414

15-
type StaticSlice<T> = &'static [T];
16-
self::shared::declare_types! {
17-
derive(Debug, Copy, Clone),
18-
str = &'static str,
19-
List = StaticSlice<_>
20-
}
15+
/// A module of definitions.
16+
#[derive(Debug, Copy, Clone)]
17+
pub struct Module(&'static [(&'static str, Binding)]);
2118

2219
impl Module {
2320
/// Try to get a bound definition in the module.
@@ -34,6 +31,40 @@ impl Module {
3431
}
3532
}
3633

34+
/// A definition bound in a module, with metadata.
35+
#[derive(Debug, Copy, Clone)]
36+
pub struct Binding {
37+
/// The bound definition.
38+
pub def: Def,
39+
/// A deprecation message for the definition, if it is deprecated.
40+
pub deprecation: Option<&'static str>,
41+
}
42+
43+
impl Binding {
44+
/// Create a new bound definition.
45+
pub const fn new(definition: Def) -> Self {
46+
Self { def: definition, deprecation: None }
47+
}
48+
}
49+
50+
/// A definition in a module.
51+
#[derive(Debug, Copy, Clone)]
52+
pub enum Def {
53+
/// A symbol, potentially with modifiers.
54+
Symbol(Symbol),
55+
/// A nested module.
56+
Module(Module),
57+
}
58+
59+
/// A symbol, either a leaf or with modifiers.
60+
#[derive(Debug, Copy, Clone)]
61+
pub enum Symbol {
62+
/// A symbol without modifiers.
63+
Single(char),
64+
/// A symbol with named modifiers. The symbol defaults to its first variant.
65+
Multi(&'static [(ModifierSet<&'static str>, char)]),
66+
}
67+
3768
impl Symbol {
3869
/// Get the symbol's character for a given set of modifiers.
3970
pub fn get(&self, modifs: ModifierSet<&str>) -> Option<char> {

src/shared.rs

Lines changed: 0 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -1,54 +1,5 @@
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-
481
use std::ops::Deref;
492

50-
pub(crate) use declare_types;
51-
523
/// A set of modifiers.
534
#[derive(Debug, Copy, Clone)]
545
// note: the visibility needs to be `pub(crate)`,

0 commit comments

Comments
 (0)