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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
#[derive(Copy, Clone, Debug, Eq, PartialEq, Hash)]
pub enum NameAliasType {
NameCorrections,
ControlCodeNames,
AlternateNames,
Figments,
NameAbbreviations,
}
impl NameAliasType {
pub fn of(ch: char) -> Option<&'static [NameAliasType]> {
data::NAME_ALIAS_TYPES.find(ch)
}
}
pub fn name_aliases_of(
ch: char,
name_alias_type: NameAliasType,
) -> Option<&'static [&'static str]> {
match name_alias_type {
NameAliasType::NameCorrections => data::CORRECTIONS.find(ch),
NameAliasType::ControlCodeNames => data::CONTROLS.find(ch),
NameAliasType::AlternateNames => data::ALTERNATES.find(ch),
NameAliasType::Figments => data::FIGMENTS.find(ch),
NameAliasType::NameAbbreviations => data::ABBREVIATIONS.find(ch),
}
}
mod data {
use unic_char_property::tables::CharDataTable;
pub const CORRECTIONS: CharDataTable<&[&str]> = include!("../tables/corrections.rsv");
pub const CONTROLS: CharDataTable<&[&str]> = include!("../tables/controls.rsv");
pub const ALTERNATES: CharDataTable<&[&str]> = include!("../tables/alternates.rsv");
pub const FIGMENTS: CharDataTable<&[&str]> = include!("../tables/figments.rsv");
pub const ABBREVIATIONS: CharDataTable<&[&str]> = include!("../tables/abbreviations.rsv");
use crate::NameAliasType::{
AlternateNames,
ControlCodeNames,
Figments,
NameAbbreviations,
NameCorrections,
};
pub const NAME_ALIAS_TYPES: CharDataTable<&[crate::NameAliasType]> =
include!("../tables/name_alias_types.rsv");
}