pub trait DecodingStyle {
fn number_to_letter(to_decode: u8, is_first: bool) -> Option<char>;
}
pub struct AllLowercase();
pub struct AllUppercase();
pub struct Titlecase();
impl DecodingStyle for AllLowercase {
#[inline(always)]
fn number_to_letter(to_decode: u8, _is_first: bool) -> Option<char> {
match to_decode {
0..=25 => Some((b'a' + to_decode) as char),
_ => None,
}
}
}
impl DecodingStyle for AllUppercase {
#[inline(always)]
fn number_to_letter(to_decode: u8, _is_first: bool) -> Option<char> {
match to_decode {
0..=25 => Some((b'A' + to_decode) as char),
_ => None,
}
}
}
impl DecodingStyle for Titlecase {
#[inline(always)]
fn number_to_letter(to_decode: u8, is_first: bool) -> Option<char> {
match to_decode {
0..=25 if is_first => Some((b'A' + to_decode) as char),
0..=25 => Some((b'a' + to_decode) as char),
_ => None,
}
}
}