use lazy_static::lazy_static;
lazy_static! {
pub static ref ALPHABET_LATIN: Alphabet = Alphabet::new(ALPHABET_LATIN_CONTENT);
pub static ref ALPHABET_USER_FRIENDLY: Alphabet = Alphabet::new(ALPHABET_USER_FRIENDLY_CONTENT);}
const ALPHABET_LATIN_CONTENT: &str = "\u{23}\u{20}\u{27}\u{28}\u{29}\u{2C}\u{2D}\u{2E}\u{2F}\u{30}\
\u{31}\u{32}\u{33}\u{34}\u{35}\u{36}\u{37}\u{38}\u{39}\u{41}\
\u{42}\u{43}\u{44}\u{45}\u{46}\u{47}\u{48}\u{49}\u{4a}\u{4b}\
\u{4c}\u{4d}\u{4e}\u{4f}\u{50}\u{51}\u{52}\u{53}\u{54}\u{55}\
\u{56}\u{57}\u{58}\u{59}\u{5a}\u{61}\u{62}\u{63}\u{64}\u{65}\
\u{66}\u{67}\u{68}\u{69}\u{6a}\u{6b}\u{6c}\u{6d}\u{6e}\u{6f}\
\u{70}\u{71}\u{72}\u{73}\u{74}\u{75}\u{76}\u{77}\u{78}\u{79}\
\u{7a}\u{a2}\u{160}\u{161}\u{17d}\u{17e}\u{152}\u{153}\u{178}\u{c0}\
\u{c1}\u{c2}\u{c3}\u{c4}\u{c5}\u{c6}\u{c7}\u{c8}\u{c9}\u{ca}\
\u{cb}\u{cc}\u{cd}\u{ce}\u{cf}\u{d0}\u{d1}\u{d2}\u{d3}\u{d4}\
\u{d5}\u{d6}\u{d8}\u{d9}\u{da}\u{db}\u{dc}\u{dd}\u{de}\u{df}\
\u{e0}\u{e1}\u{e2}\u{e3}\u{e4}\u{e5}\u{e6}\u{e7}\u{e8}\u{e9}\
\u{ea}\u{eb}\u{ec}\u{ed}\u{ee}\u{ef}\u{f0}\u{f1}\u{f2}\u{f3}\
\u{f4}\u{f5}\u{f6}\u{f8}\u{f9}\u{fa}\u{fb}\u{fc}\u{fd}\u{fe}\
\u{ff}";
const ALPHABET_USER_FRIENDLY_CONTENT: &str = "abcdefghijkmnpqrstuvwxyz23456789";
pub struct Alphabet(&'static str);
impl Alphabet {
pub fn new(chars: &'static str) -> Self {
Self(chars)
}
pub fn size(&self) -> usize {
self.0.chars().count()
}
pub fn character_at_pos(&self, pos: usize) -> Option<char> {
self.0.chars().nth(pos)
}
}
#[cfg(test)]
mod test {
use super::*;
#[test]
fn test_latin() {
assert_eq!(ALPHABET_LATIN.size(), 141);
assert_eq!(ALPHABET_LATIN.character_at_pos(14), Some('5'));
assert_eq!(ALPHABET_LATIN.character_at_pos(28), Some('J'));
assert_eq!(ALPHABET_LATIN.character_at_pos(125), Some('ï'));
}
}