unicode_types/generated/
lycian.rs

1
2/// An enum to represent all characters in the Lycian block.
3#[derive(Debug, Clone, Copy, Hash, PartialEq, Eq)]
4pub enum Lycian {
5    /// \u{10280}: '𐊀'
6    LetterA,
7    /// \u{10281}: '𐊁'
8    LetterE,
9    /// \u{10282}: '𐊂'
10    LetterB,
11    /// \u{10283}: '𐊃'
12    LetterBh,
13    /// \u{10284}: '𐊄'
14    LetterG,
15    /// \u{10285}: '𐊅'
16    LetterD,
17    /// \u{10286}: '𐊆'
18    LetterI,
19    /// \u{10287}: '𐊇'
20    LetterW,
21    /// \u{10288}: '𐊈'
22    LetterZ,
23    /// \u{10289}: '𐊉'
24    LetterTh,
25    /// \u{1028a}: '𐊊'
26    LetterJ,
27    /// \u{1028b}: '𐊋'
28    LetterK,
29    /// \u{1028c}: '𐊌'
30    LetterQ,
31    /// \u{1028d}: '𐊍'
32    LetterL,
33    /// \u{1028e}: '𐊎'
34    LetterM,
35    /// \u{1028f}: '𐊏'
36    LetterN,
37    /// \u{10290}: '𐊐'
38    LetterMm,
39    /// \u{10291}: '𐊑'
40    LetterNn,
41    /// \u{10292}: '𐊒'
42    LetterU,
43    /// \u{10293}: '𐊓'
44    LetterP,
45    /// \u{10294}: '𐊔'
46    LetterKk,
47    /// \u{10295}: '𐊕'
48    LetterR,
49    /// \u{10296}: '𐊖'
50    LetterS,
51    /// \u{10297}: '𐊗'
52    LetterT,
53    /// \u{10298}: '𐊘'
54    LetterTt,
55    /// \u{10299}: '𐊙'
56    LetterAn,
57    /// \u{1029a}: '𐊚'
58    LetterEn,
59    /// \u{1029b}: '𐊛'
60    LetterH,
61    /// \u{1029c}: '𐊜'
62    LetterX,
63}
64
65impl Into<char> for Lycian {
66    fn into(self) -> char {
67        match self {
68            Lycian::LetterA => '𐊀',
69            Lycian::LetterE => '𐊁',
70            Lycian::LetterB => '𐊂',
71            Lycian::LetterBh => '𐊃',
72            Lycian::LetterG => '𐊄',
73            Lycian::LetterD => '𐊅',
74            Lycian::LetterI => '𐊆',
75            Lycian::LetterW => '𐊇',
76            Lycian::LetterZ => '𐊈',
77            Lycian::LetterTh => '𐊉',
78            Lycian::LetterJ => '𐊊',
79            Lycian::LetterK => '𐊋',
80            Lycian::LetterQ => '𐊌',
81            Lycian::LetterL => '𐊍',
82            Lycian::LetterM => '𐊎',
83            Lycian::LetterN => '𐊏',
84            Lycian::LetterMm => '𐊐',
85            Lycian::LetterNn => '𐊑',
86            Lycian::LetterU => '𐊒',
87            Lycian::LetterP => '𐊓',
88            Lycian::LetterKk => '𐊔',
89            Lycian::LetterR => '𐊕',
90            Lycian::LetterS => '𐊖',
91            Lycian::LetterT => '𐊗',
92            Lycian::LetterTt => '𐊘',
93            Lycian::LetterAn => '𐊙',
94            Lycian::LetterEn => '𐊚',
95            Lycian::LetterH => '𐊛',
96            Lycian::LetterX => '𐊜',
97        }
98    }
99}
100
101impl std::convert::TryFrom<char> for Lycian {
102    type Error = ();
103    fn try_from(c: char) -> Result<Self, Self::Error> {
104        match c {
105            '𐊀' => Ok(Lycian::LetterA),
106            '𐊁' => Ok(Lycian::LetterE),
107            '𐊂' => Ok(Lycian::LetterB),
108            '𐊃' => Ok(Lycian::LetterBh),
109            '𐊄' => Ok(Lycian::LetterG),
110            '𐊅' => Ok(Lycian::LetterD),
111            '𐊆' => Ok(Lycian::LetterI),
112            '𐊇' => Ok(Lycian::LetterW),
113            '𐊈' => Ok(Lycian::LetterZ),
114            '𐊉' => Ok(Lycian::LetterTh),
115            '𐊊' => Ok(Lycian::LetterJ),
116            '𐊋' => Ok(Lycian::LetterK),
117            '𐊌' => Ok(Lycian::LetterQ),
118            '𐊍' => Ok(Lycian::LetterL),
119            '𐊎' => Ok(Lycian::LetterM),
120            '𐊏' => Ok(Lycian::LetterN),
121            '𐊐' => Ok(Lycian::LetterMm),
122            '𐊑' => Ok(Lycian::LetterNn),
123            '𐊒' => Ok(Lycian::LetterU),
124            '𐊓' => Ok(Lycian::LetterP),
125            '𐊔' => Ok(Lycian::LetterKk),
126            '𐊕' => Ok(Lycian::LetterR),
127            '𐊖' => Ok(Lycian::LetterS),
128            '𐊗' => Ok(Lycian::LetterT),
129            '𐊘' => Ok(Lycian::LetterTt),
130            '𐊙' => Ok(Lycian::LetterAn),
131            '𐊚' => Ok(Lycian::LetterEn),
132            '𐊛' => Ok(Lycian::LetterH),
133            '𐊜' => Ok(Lycian::LetterX),
134            _ => Err(()),
135        }
136    }
137}
138
139impl Into<u32> for Lycian {
140    fn into(self) -> u32 {
141        let c: char = self.into();
142        let hex = c
143            .escape_unicode()
144            .to_string()
145            .replace("\\u{", "")
146            .replace("}", "");
147        u32::from_str_radix(&hex, 16).unwrap()
148    }
149}
150
151impl std::convert::TryFrom<u32> for Lycian {
152    type Error = ();
153    fn try_from(u: u32) -> Result<Self, Self::Error> {
154        if let Ok(c) = char::try_from(u) {
155            Self::try_from(c)
156        } else {
157            Err(())
158        }
159    }
160}
161
162impl Iterator for Lycian {
163    type Item = Self;
164    fn next(&mut self) -> Option<Self> {
165        let index: u32 = (*self).into();
166        use std::convert::TryFrom;
167        Self::try_from(index + 1).ok()
168    }
169}
170
171impl Lycian {
172    /// The character with the lowest index in this unicode block
173    pub fn new() -> Self {
174        Lycian::LetterA
175    }
176
177    /// The character's name, in sentence case
178    pub fn name(&self) -> String {
179        let s = std::format!("Lycian{:#?}", self);
180        string_morph::to_sentence_case(&s)
181    }
182}