Skip to content

Commit 1fdbb1e

Browse files
committed
Use a more idiomatic module structure
1 parent 4895855 commit 1fdbb1e

File tree

3 files changed

+14
-6
lines changed

3 files changed

+14
-6
lines changed

build.rs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
1+
use self::shared::ModifierSet;
12
use std::fmt::Write;
23
use std::iter::Peekable;
34
use std::path::Path;
45

56
type StrResult<T> = Result<T, String>;
67

7-
include!("src/shared.rs");
8+
#[path = "src/shared.rs"]
9+
mod shared;
810

9-
declare_types!{
11+
self::shared::declare_types! {
1012
<'a>
1113
str = &'a str,
1214
List = Vec<_>
@@ -97,7 +99,7 @@ fn tokenize(line: &str) -> StrResult<Line> {
9799
validate_ident(part)?;
98100
}
99101
let c = decode_char(tail.ok_or("missing char")?)?;
100-
Line::Variant(ModifierSet(rest), c)
102+
Line::Variant(ModifierSet::new_unchecked(rest), c)
101103
} else {
102104
validate_ident(head)?;
103105
let c = tail.map(decode_char).transpose()?;

src/lib.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,12 @@
88
//! that don't contain the character `.`, but codex only defines
99
//! ones that are entirely made of ASCII alphabetical characters.
1010
11-
include!("shared.rs");
11+
pub use self::shared::ModifierSet;
12+
13+
mod shared;
1214

1315
type StaticSlice<T> = &'static [T];
14-
declare_types! {
16+
self::shared::declare_types! {
1517
derive(Debug, Copy, Clone),
1618
str = &'static str,
1719
List = StaticSlice<_>

src/shared.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,13 @@ macro_rules! declare_types {
4545
};
4646
}
4747

48+
pub(crate) use declare_types;
49+
4850
/// A set of modifiers.
4951
#[derive(Debug, Copy, Clone)]
50-
pub struct ModifierSet<S>(S);
52+
// note: the visibility needs to be `pub(crate)`,
53+
// since build.rs outputs `ModifierSet(...)`
54+
pub struct ModifierSet<S>(pub(crate) S);
5155

5256
impl<S: Default> Default for ModifierSet<S> {
5357
/// Construct the default modifier set.

0 commit comments

Comments
 (0)