mod constants {
pub const LETTER_ALF: char = '𐤀';
pub const LETTER_BET: char = '𐤁';
pub const LETTER_GAML: char = '𐤂';
pub const LETTER_DELT: char = '𐤃';
pub const LETTER_HE: char = '𐤄';
pub const LETTER_WAU: char = '𐤅';
pub const LETTER_ZAI: char = '𐤆';
pub const LETTER_HET: char = '𐤇';
pub const LETTER_TET: char = '𐤈';
pub const LETTER_YOD: char = '𐤉';
pub const LETTER_KAF: char = '𐤊';
pub const LETTER_LAMD: char = '𐤋';
pub const LETTER_MEM: char = '𐤌';
pub const LETTER_NUN: char = '𐤍';
pub const LETTER_SEMK: char = '𐤎';
pub const LETTER_AIN: char = '𐤏';
pub const LETTER_PE: char = '𐤐';
pub const LETTER_SADE: char = '𐤑';
pub const LETTER_QOF: char = '𐤒';
pub const LETTER_ROSH: char = '𐤓';
pub const LETTER_SHIN: char = '𐤔';
pub const LETTER_TAU: char = '𐤕';
pub const NUMBER_ONE: char = '𐤖';
pub const NUMBER_TEN: char = '𐤗';
pub const NUMBER_TWENTY: char = '𐤘';
pub const NUMBER_ONE_HUNDRED: char = '𐤙';
pub const NUMBER_TWO: char = '𐤚';
pub const NUMBER_THREE: char = '𐤛';
}
#[derive(Debug, Clone, Copy, Hash, PartialEq, Eq)]
pub enum Phoenician {
LetterAlf,
LetterBet,
LetterGaml,
LetterDelt,
LetterHe,
LetterWau,
LetterZai,
LetterHet,
LetterTet,
LetterYod,
LetterKaf,
LetterLamd,
LetterMem,
LetterNun,
LetterSemk,
LetterAin,
LetterPe,
LetterSade,
LetterQof,
LetterRosh,
LetterShin,
LetterTau,
NumberOne,
NumberTen,
NumberTwenty,
NumberOneHundred,
NumberTwo,
NumberThree,
}
impl Into<char> for Phoenician {
fn into(self) -> char {
use constants::*;
match self {
Phoenician::LetterAlf => LETTER_ALF,
Phoenician::LetterBet => LETTER_BET,
Phoenician::LetterGaml => LETTER_GAML,
Phoenician::LetterDelt => LETTER_DELT,
Phoenician::LetterHe => LETTER_HE,
Phoenician::LetterWau => LETTER_WAU,
Phoenician::LetterZai => LETTER_ZAI,
Phoenician::LetterHet => LETTER_HET,
Phoenician::LetterTet => LETTER_TET,
Phoenician::LetterYod => LETTER_YOD,
Phoenician::LetterKaf => LETTER_KAF,
Phoenician::LetterLamd => LETTER_LAMD,
Phoenician::LetterMem => LETTER_MEM,
Phoenician::LetterNun => LETTER_NUN,
Phoenician::LetterSemk => LETTER_SEMK,
Phoenician::LetterAin => LETTER_AIN,
Phoenician::LetterPe => LETTER_PE,
Phoenician::LetterSade => LETTER_SADE,
Phoenician::LetterQof => LETTER_QOF,
Phoenician::LetterRosh => LETTER_ROSH,
Phoenician::LetterShin => LETTER_SHIN,
Phoenician::LetterTau => LETTER_TAU,
Phoenician::NumberOne => NUMBER_ONE,
Phoenician::NumberTen => NUMBER_TEN,
Phoenician::NumberTwenty => NUMBER_TWENTY,
Phoenician::NumberOneHundred => NUMBER_ONE_HUNDRED,
Phoenician::NumberTwo => NUMBER_TWO,
Phoenician::NumberThree => NUMBER_THREE,
}
}
}
impl std::convert::TryFrom<char> for Phoenician {
type Error = ();
fn try_from(c: char) -> Result<Self, Self::Error> {
use constants::*;
match c {
LETTER_ALF => Ok(Phoenician::LetterAlf),
LETTER_BET => Ok(Phoenician::LetterBet),
LETTER_GAML => Ok(Phoenician::LetterGaml),
LETTER_DELT => Ok(Phoenician::LetterDelt),
LETTER_HE => Ok(Phoenician::LetterHe),
LETTER_WAU => Ok(Phoenician::LetterWau),
LETTER_ZAI => Ok(Phoenician::LetterZai),
LETTER_HET => Ok(Phoenician::LetterHet),
LETTER_TET => Ok(Phoenician::LetterTet),
LETTER_YOD => Ok(Phoenician::LetterYod),
LETTER_KAF => Ok(Phoenician::LetterKaf),
LETTER_LAMD => Ok(Phoenician::LetterLamd),
LETTER_MEM => Ok(Phoenician::LetterMem),
LETTER_NUN => Ok(Phoenician::LetterNun),
LETTER_SEMK => Ok(Phoenician::LetterSemk),
LETTER_AIN => Ok(Phoenician::LetterAin),
LETTER_PE => Ok(Phoenician::LetterPe),
LETTER_SADE => Ok(Phoenician::LetterSade),
LETTER_QOF => Ok(Phoenician::LetterQof),
LETTER_ROSH => Ok(Phoenician::LetterRosh),
LETTER_SHIN => Ok(Phoenician::LetterShin),
LETTER_TAU => Ok(Phoenician::LetterTau),
NUMBER_ONE => Ok(Phoenician::NumberOne),
NUMBER_TEN => Ok(Phoenician::NumberTen),
NUMBER_TWENTY => Ok(Phoenician::NumberTwenty),
NUMBER_ONE_HUNDRED => Ok(Phoenician::NumberOneHundred),
NUMBER_TWO => Ok(Phoenician::NumberTwo),
NUMBER_THREE => Ok(Phoenician::NumberThree),
_ => Err(()),
}
}
}
impl Into<u32> for Phoenician {
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 Phoenician {
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 Phoenician {
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 Phoenician {
pub fn new() -> Self {
Phoenician::LetterAlf
}
pub fn name(&self) -> &str {
match self {
Phoenician::LetterAlf => "phoenician letter alf",
Phoenician::LetterBet => "phoenician letter bet",
Phoenician::LetterGaml => "phoenician letter gaml",
Phoenician::LetterDelt => "phoenician letter delt",
Phoenician::LetterHe => "phoenician letter he",
Phoenician::LetterWau => "phoenician letter wau",
Phoenician::LetterZai => "phoenician letter zai",
Phoenician::LetterHet => "phoenician letter het",
Phoenician::LetterTet => "phoenician letter tet",
Phoenician::LetterYod => "phoenician letter yod",
Phoenician::LetterKaf => "phoenician letter kaf",
Phoenician::LetterLamd => "phoenician letter lamd",
Phoenician::LetterMem => "phoenician letter mem",
Phoenician::LetterNun => "phoenician letter nun",
Phoenician::LetterSemk => "phoenician letter semk",
Phoenician::LetterAin => "phoenician letter ain",
Phoenician::LetterPe => "phoenician letter pe",
Phoenician::LetterSade => "phoenician letter sade",
Phoenician::LetterQof => "phoenician letter qof",
Phoenician::LetterRosh => "phoenician letter rosh",
Phoenician::LetterShin => "phoenician letter shin",
Phoenician::LetterTau => "phoenician letter tau",
Phoenician::NumberOne => "phoenician number one",
Phoenician::NumberTen => "phoenician number ten",
Phoenician::NumberTwenty => "phoenician number twenty",
Phoenician::NumberOneHundred => "phoenician number one hundred",
Phoenician::NumberTwo => "phoenician number two",
Phoenician::NumberThree => "phoenician number three",
}
}
}