#[derive(Debug, Clone, Copy, Hash, PartialEq, Eq)]
pub enum Elymaic {
LetterAleph,
LetterBeth,
LetterGimel,
LetterDaleth,
LetterHe,
LetterWaw,
LetterZayin,
LetterHeth,
LetterTeth,
LetterYodh,
LetterKaph,
LetterLamedh,
LetterMem,
LetterNun,
LetterSamekh,
LetterAyin,
LetterPe,
LetterSadhe,
LetterQoph,
LetterResh,
LetterShin,
LetterTaw,
LigatureZayinDashYodh,
}
impl Into<char> for Elymaic {
fn into(self) -> char {
match self {
Elymaic::LetterAleph => '𐿠',
Elymaic::LetterBeth => '𐿡',
Elymaic::LetterGimel => '𐿢',
Elymaic::LetterDaleth => '𐿣',
Elymaic::LetterHe => '𐿤',
Elymaic::LetterWaw => '𐿥',
Elymaic::LetterZayin => '𐿦',
Elymaic::LetterHeth => '𐿧',
Elymaic::LetterTeth => '𐿨',
Elymaic::LetterYodh => '𐿩',
Elymaic::LetterKaph => '𐿪',
Elymaic::LetterLamedh => '𐿫',
Elymaic::LetterMem => '𐿬',
Elymaic::LetterNun => '𐿭',
Elymaic::LetterSamekh => '𐿮',
Elymaic::LetterAyin => '𐿯',
Elymaic::LetterPe => '𐿰',
Elymaic::LetterSadhe => '𐿱',
Elymaic::LetterQoph => '𐿲',
Elymaic::LetterResh => '𐿳',
Elymaic::LetterShin => '𐿴',
Elymaic::LetterTaw => '𐿵',
Elymaic::LigatureZayinDashYodh => '𐿶',
}
}
}
impl std::convert::TryFrom<char> for Elymaic {
type Error = ();
fn try_from(c: char) -> Result<Self, Self::Error> {
match c {
'𐿠' => Ok(Elymaic::LetterAleph),
'𐿡' => Ok(Elymaic::LetterBeth),
'𐿢' => Ok(Elymaic::LetterGimel),
'𐿣' => Ok(Elymaic::LetterDaleth),
'𐿤' => Ok(Elymaic::LetterHe),
'𐿥' => Ok(Elymaic::LetterWaw),
'𐿦' => Ok(Elymaic::LetterZayin),
'𐿧' => Ok(Elymaic::LetterHeth),
'𐿨' => Ok(Elymaic::LetterTeth),
'𐿩' => Ok(Elymaic::LetterYodh),
'𐿪' => Ok(Elymaic::LetterKaph),
'𐿫' => Ok(Elymaic::LetterLamedh),
'𐿬' => Ok(Elymaic::LetterMem),
'𐿭' => Ok(Elymaic::LetterNun),
'𐿮' => Ok(Elymaic::LetterSamekh),
'𐿯' => Ok(Elymaic::LetterAyin),
'𐿰' => Ok(Elymaic::LetterPe),
'𐿱' => Ok(Elymaic::LetterSadhe),
'𐿲' => Ok(Elymaic::LetterQoph),
'𐿳' => Ok(Elymaic::LetterResh),
'𐿴' => Ok(Elymaic::LetterShin),
'𐿵' => Ok(Elymaic::LetterTaw),
'𐿶' => Ok(Elymaic::LigatureZayinDashYodh),
_ => Err(()),
}
}
}
impl Into<u32> for Elymaic {
fn into(self) -> u32 {
let c: char = self.into();
let hex = c
.escape_unicode()
.to_string()
.replace("\\u{", "")
.replace("}", "");
u32::from_str_radix(&hex, 16).unwrap()
}
}
impl std::convert::TryFrom<u32> for Elymaic {
type Error = ();
fn try_from(u: u32) -> Result<Self, Self::Error> {
if let Ok(c) = char::try_from(u) {
Self::try_from(c)
} else {
Err(())
}
}
}
impl Iterator for Elymaic {
type Item = Self;
fn next(&mut self) -> Option<Self> {
let index: u32 = (*self).into();
use std::convert::TryFrom;
Self::try_from(index + 1).ok()
}
}
impl Elymaic {
pub fn new() -> Self {
Elymaic::LetterAleph
}
pub fn name(&self) -> String {
let s = std::format!("Elymaic{:#?}", self);
string_morph::to_sentence_case(&s)
}
}