mod constants {
pub const SUPERSCRIPT_ZERO: char = '⁰';
pub const SUPERSCRIPT_LATIN_SMALL_LETTER_I: char = 'ⁱ';
pub const SUPERSCRIPT_FOUR: char = '⁴';
pub const SUPERSCRIPT_FIVE: char = '⁵';
pub const SUPERSCRIPT_SIX: char = '⁶';
pub const SUPERSCRIPT_SEVEN: char = '⁷';
pub const SUPERSCRIPT_EIGHT: char = '⁸';
pub const SUPERSCRIPT_NINE: char = '⁹';
pub const SUPERSCRIPT_PLUS_SIGN: char = '⁺';
pub const SUPERSCRIPT_MINUS: char = '⁻';
pub const SUPERSCRIPT_EQUALS_SIGN: char = '⁼';
pub const SUPERSCRIPT_LEFT_PARENTHESIS: char = '⁽';
pub const SUPERSCRIPT_RIGHT_PARENTHESIS: char = '⁾';
pub const SUPERSCRIPT_LATIN_SMALL_LETTER_N: char = 'ⁿ';
pub const SUBSCRIPT_ZERO: char = '₀';
pub const SUBSCRIPT_ONE: char = '₁';
pub const SUBSCRIPT_TWO: char = '₂';
pub const SUBSCRIPT_THREE: char = '₃';
pub const SUBSCRIPT_FOUR: char = '₄';
pub const SUBSCRIPT_FIVE: char = '₅';
pub const SUBSCRIPT_SIX: char = '₆';
pub const SUBSCRIPT_SEVEN: char = '₇';
pub const SUBSCRIPT_EIGHT: char = '₈';
pub const SUBSCRIPT_NINE: char = '₉';
pub const SUBSCRIPT_PLUS_SIGN: char = '₊';
pub const SUBSCRIPT_MINUS: char = '₋';
pub const SUBSCRIPT_EQUALS_SIGN: char = '₌';
pub const SUBSCRIPT_LEFT_PARENTHESIS: char = '₍';
pub const SUBSCRIPT_RIGHT_PARENTHESIS: char = '₎';
pub const LATIN_SUBSCRIPT_SMALL_LETTER_A: char = 'ₐ';
pub const LATIN_SUBSCRIPT_SMALL_LETTER_E: char = 'ₑ';
pub const LATIN_SUBSCRIPT_SMALL_LETTER_O: char = 'ₒ';
pub const LATIN_SUBSCRIPT_SMALL_LETTER_X: char = 'ₓ';
pub const LATIN_SUBSCRIPT_SMALL_LETTER_SCHWA: char = 'ₔ';
pub const LATIN_SUBSCRIPT_SMALL_LETTER_H: char = 'ₕ';
pub const LATIN_SUBSCRIPT_SMALL_LETTER_K: char = 'ₖ';
pub const LATIN_SUBSCRIPT_SMALL_LETTER_L: char = 'ₗ';
pub const LATIN_SUBSCRIPT_SMALL_LETTER_M: char = 'ₘ';
pub const LATIN_SUBSCRIPT_SMALL_LETTER_N: char = 'ₙ';
pub const LATIN_SUBSCRIPT_SMALL_LETTER_P: char = 'ₚ';
pub const LATIN_SUBSCRIPT_SMALL_LETTER_S: char = 'ₛ';
pub const LATIN_SUBSCRIPT_SMALL_LETTER_T: char = 'ₜ';
}
#[derive(Debug, Clone, Copy, Hash, PartialEq, Eq)]
pub enum SuperscriptsandSubscripts {
SuperscriptZero,
SuperscriptLatinSmallLetterI,
SuperscriptFour,
SuperscriptFive,
SuperscriptSix,
SuperscriptSeven,
SuperscriptEight,
SuperscriptNine,
SuperscriptPlusSign,
SuperscriptMinus,
SuperscriptEqualsSign,
SuperscriptLeftParenthesis,
SuperscriptRightParenthesis,
SuperscriptLatinSmallLetterN,
SubscriptZero,
SubscriptOne,
SubscriptTwo,
SubscriptThree,
SubscriptFour,
SubscriptFive,
SubscriptSix,
SubscriptSeven,
SubscriptEight,
SubscriptNine,
SubscriptPlusSign,
SubscriptMinus,
SubscriptEqualsSign,
SubscriptLeftParenthesis,
SubscriptRightParenthesis,
LatinSubscriptSmallLetterA,
LatinSubscriptSmallLetterE,
LatinSubscriptSmallLetterO,
LatinSubscriptSmallLetterX,
LatinSubscriptSmallLetterSchwa,
LatinSubscriptSmallLetterH,
LatinSubscriptSmallLetterK,
LatinSubscriptSmallLetterL,
LatinSubscriptSmallLetterM,
LatinSubscriptSmallLetterN,
LatinSubscriptSmallLetterP,
LatinSubscriptSmallLetterS,
LatinSubscriptSmallLetterT,
}
impl Into<char> for SuperscriptsandSubscripts {
fn into(self) -> char {
use constants::*;
match self {
SuperscriptsandSubscripts::SuperscriptZero => SUPERSCRIPT_ZERO,
SuperscriptsandSubscripts::SuperscriptLatinSmallLetterI => SUPERSCRIPT_LATIN_SMALL_LETTER_I,
SuperscriptsandSubscripts::SuperscriptFour => SUPERSCRIPT_FOUR,
SuperscriptsandSubscripts::SuperscriptFive => SUPERSCRIPT_FIVE,
SuperscriptsandSubscripts::SuperscriptSix => SUPERSCRIPT_SIX,
SuperscriptsandSubscripts::SuperscriptSeven => SUPERSCRIPT_SEVEN,
SuperscriptsandSubscripts::SuperscriptEight => SUPERSCRIPT_EIGHT,
SuperscriptsandSubscripts::SuperscriptNine => SUPERSCRIPT_NINE,
SuperscriptsandSubscripts::SuperscriptPlusSign => SUPERSCRIPT_PLUS_SIGN,
SuperscriptsandSubscripts::SuperscriptMinus => SUPERSCRIPT_MINUS,
SuperscriptsandSubscripts::SuperscriptEqualsSign => SUPERSCRIPT_EQUALS_SIGN,
SuperscriptsandSubscripts::SuperscriptLeftParenthesis => SUPERSCRIPT_LEFT_PARENTHESIS,
SuperscriptsandSubscripts::SuperscriptRightParenthesis => SUPERSCRIPT_RIGHT_PARENTHESIS,
SuperscriptsandSubscripts::SuperscriptLatinSmallLetterN => SUPERSCRIPT_LATIN_SMALL_LETTER_N,
SuperscriptsandSubscripts::SubscriptZero => SUBSCRIPT_ZERO,
SuperscriptsandSubscripts::SubscriptOne => SUBSCRIPT_ONE,
SuperscriptsandSubscripts::SubscriptTwo => SUBSCRIPT_TWO,
SuperscriptsandSubscripts::SubscriptThree => SUBSCRIPT_THREE,
SuperscriptsandSubscripts::SubscriptFour => SUBSCRIPT_FOUR,
SuperscriptsandSubscripts::SubscriptFive => SUBSCRIPT_FIVE,
SuperscriptsandSubscripts::SubscriptSix => SUBSCRIPT_SIX,
SuperscriptsandSubscripts::SubscriptSeven => SUBSCRIPT_SEVEN,
SuperscriptsandSubscripts::SubscriptEight => SUBSCRIPT_EIGHT,
SuperscriptsandSubscripts::SubscriptNine => SUBSCRIPT_NINE,
SuperscriptsandSubscripts::SubscriptPlusSign => SUBSCRIPT_PLUS_SIGN,
SuperscriptsandSubscripts::SubscriptMinus => SUBSCRIPT_MINUS,
SuperscriptsandSubscripts::SubscriptEqualsSign => SUBSCRIPT_EQUALS_SIGN,
SuperscriptsandSubscripts::SubscriptLeftParenthesis => SUBSCRIPT_LEFT_PARENTHESIS,
SuperscriptsandSubscripts::SubscriptRightParenthesis => SUBSCRIPT_RIGHT_PARENTHESIS,
SuperscriptsandSubscripts::LatinSubscriptSmallLetterA => LATIN_SUBSCRIPT_SMALL_LETTER_A,
SuperscriptsandSubscripts::LatinSubscriptSmallLetterE => LATIN_SUBSCRIPT_SMALL_LETTER_E,
SuperscriptsandSubscripts::LatinSubscriptSmallLetterO => LATIN_SUBSCRIPT_SMALL_LETTER_O,
SuperscriptsandSubscripts::LatinSubscriptSmallLetterX => LATIN_SUBSCRIPT_SMALL_LETTER_X,
SuperscriptsandSubscripts::LatinSubscriptSmallLetterSchwa => LATIN_SUBSCRIPT_SMALL_LETTER_SCHWA,
SuperscriptsandSubscripts::LatinSubscriptSmallLetterH => LATIN_SUBSCRIPT_SMALL_LETTER_H,
SuperscriptsandSubscripts::LatinSubscriptSmallLetterK => LATIN_SUBSCRIPT_SMALL_LETTER_K,
SuperscriptsandSubscripts::LatinSubscriptSmallLetterL => LATIN_SUBSCRIPT_SMALL_LETTER_L,
SuperscriptsandSubscripts::LatinSubscriptSmallLetterM => LATIN_SUBSCRIPT_SMALL_LETTER_M,
SuperscriptsandSubscripts::LatinSubscriptSmallLetterN => LATIN_SUBSCRIPT_SMALL_LETTER_N,
SuperscriptsandSubscripts::LatinSubscriptSmallLetterP => LATIN_SUBSCRIPT_SMALL_LETTER_P,
SuperscriptsandSubscripts::LatinSubscriptSmallLetterS => LATIN_SUBSCRIPT_SMALL_LETTER_S,
SuperscriptsandSubscripts::LatinSubscriptSmallLetterT => LATIN_SUBSCRIPT_SMALL_LETTER_T,
}
}
}
impl std::convert::TryFrom<char> for SuperscriptsandSubscripts {
type Error = ();
fn try_from(c: char) -> Result<Self, Self::Error> {
use constants::*;
match c {
SUPERSCRIPT_ZERO => Ok(SuperscriptsandSubscripts::SuperscriptZero),
SUPERSCRIPT_LATIN_SMALL_LETTER_I => Ok(SuperscriptsandSubscripts::SuperscriptLatinSmallLetterI),
SUPERSCRIPT_FOUR => Ok(SuperscriptsandSubscripts::SuperscriptFour),
SUPERSCRIPT_FIVE => Ok(SuperscriptsandSubscripts::SuperscriptFive),
SUPERSCRIPT_SIX => Ok(SuperscriptsandSubscripts::SuperscriptSix),
SUPERSCRIPT_SEVEN => Ok(SuperscriptsandSubscripts::SuperscriptSeven),
SUPERSCRIPT_EIGHT => Ok(SuperscriptsandSubscripts::SuperscriptEight),
SUPERSCRIPT_NINE => Ok(SuperscriptsandSubscripts::SuperscriptNine),
SUPERSCRIPT_PLUS_SIGN => Ok(SuperscriptsandSubscripts::SuperscriptPlusSign),
SUPERSCRIPT_MINUS => Ok(SuperscriptsandSubscripts::SuperscriptMinus),
SUPERSCRIPT_EQUALS_SIGN => Ok(SuperscriptsandSubscripts::SuperscriptEqualsSign),
SUPERSCRIPT_LEFT_PARENTHESIS => Ok(SuperscriptsandSubscripts::SuperscriptLeftParenthesis),
SUPERSCRIPT_RIGHT_PARENTHESIS => Ok(SuperscriptsandSubscripts::SuperscriptRightParenthesis),
SUPERSCRIPT_LATIN_SMALL_LETTER_N => Ok(SuperscriptsandSubscripts::SuperscriptLatinSmallLetterN),
SUBSCRIPT_ZERO => Ok(SuperscriptsandSubscripts::SubscriptZero),
SUBSCRIPT_ONE => Ok(SuperscriptsandSubscripts::SubscriptOne),
SUBSCRIPT_TWO => Ok(SuperscriptsandSubscripts::SubscriptTwo),
SUBSCRIPT_THREE => Ok(SuperscriptsandSubscripts::SubscriptThree),
SUBSCRIPT_FOUR => Ok(SuperscriptsandSubscripts::SubscriptFour),
SUBSCRIPT_FIVE => Ok(SuperscriptsandSubscripts::SubscriptFive),
SUBSCRIPT_SIX => Ok(SuperscriptsandSubscripts::SubscriptSix),
SUBSCRIPT_SEVEN => Ok(SuperscriptsandSubscripts::SubscriptSeven),
SUBSCRIPT_EIGHT => Ok(SuperscriptsandSubscripts::SubscriptEight),
SUBSCRIPT_NINE => Ok(SuperscriptsandSubscripts::SubscriptNine),
SUBSCRIPT_PLUS_SIGN => Ok(SuperscriptsandSubscripts::SubscriptPlusSign),
SUBSCRIPT_MINUS => Ok(SuperscriptsandSubscripts::SubscriptMinus),
SUBSCRIPT_EQUALS_SIGN => Ok(SuperscriptsandSubscripts::SubscriptEqualsSign),
SUBSCRIPT_LEFT_PARENTHESIS => Ok(SuperscriptsandSubscripts::SubscriptLeftParenthesis),
SUBSCRIPT_RIGHT_PARENTHESIS => Ok(SuperscriptsandSubscripts::SubscriptRightParenthesis),
LATIN_SUBSCRIPT_SMALL_LETTER_A => Ok(SuperscriptsandSubscripts::LatinSubscriptSmallLetterA),
LATIN_SUBSCRIPT_SMALL_LETTER_E => Ok(SuperscriptsandSubscripts::LatinSubscriptSmallLetterE),
LATIN_SUBSCRIPT_SMALL_LETTER_O => Ok(SuperscriptsandSubscripts::LatinSubscriptSmallLetterO),
LATIN_SUBSCRIPT_SMALL_LETTER_X => Ok(SuperscriptsandSubscripts::LatinSubscriptSmallLetterX),
LATIN_SUBSCRIPT_SMALL_LETTER_SCHWA => Ok(SuperscriptsandSubscripts::LatinSubscriptSmallLetterSchwa),
LATIN_SUBSCRIPT_SMALL_LETTER_H => Ok(SuperscriptsandSubscripts::LatinSubscriptSmallLetterH),
LATIN_SUBSCRIPT_SMALL_LETTER_K => Ok(SuperscriptsandSubscripts::LatinSubscriptSmallLetterK),
LATIN_SUBSCRIPT_SMALL_LETTER_L => Ok(SuperscriptsandSubscripts::LatinSubscriptSmallLetterL),
LATIN_SUBSCRIPT_SMALL_LETTER_M => Ok(SuperscriptsandSubscripts::LatinSubscriptSmallLetterM),
LATIN_SUBSCRIPT_SMALL_LETTER_N => Ok(SuperscriptsandSubscripts::LatinSubscriptSmallLetterN),
LATIN_SUBSCRIPT_SMALL_LETTER_P => Ok(SuperscriptsandSubscripts::LatinSubscriptSmallLetterP),
LATIN_SUBSCRIPT_SMALL_LETTER_S => Ok(SuperscriptsandSubscripts::LatinSubscriptSmallLetterS),
LATIN_SUBSCRIPT_SMALL_LETTER_T => Ok(SuperscriptsandSubscripts::LatinSubscriptSmallLetterT),
_ => Err(()),
}
}
}
impl Into<u32> for SuperscriptsandSubscripts {
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 SuperscriptsandSubscripts {
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 SuperscriptsandSubscripts {
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 SuperscriptsandSubscripts {
pub fn new() -> Self {
SuperscriptsandSubscripts::SuperscriptZero
}
pub fn name(&self) -> &str {
match self {
SuperscriptsandSubscripts::SuperscriptZero => "superscript zero",
SuperscriptsandSubscripts::SuperscriptLatinSmallLetterI => "superscript latin small letter i",
SuperscriptsandSubscripts::SuperscriptFour => "superscript four",
SuperscriptsandSubscripts::SuperscriptFive => "superscript five",
SuperscriptsandSubscripts::SuperscriptSix => "superscript six",
SuperscriptsandSubscripts::SuperscriptSeven => "superscript seven",
SuperscriptsandSubscripts::SuperscriptEight => "superscript eight",
SuperscriptsandSubscripts::SuperscriptNine => "superscript nine",
SuperscriptsandSubscripts::SuperscriptPlusSign => "superscript plus sign",
SuperscriptsandSubscripts::SuperscriptMinus => "superscript minus",
SuperscriptsandSubscripts::SuperscriptEqualsSign => "superscript equals sign",
SuperscriptsandSubscripts::SuperscriptLeftParenthesis => "superscript left parenthesis",
SuperscriptsandSubscripts::SuperscriptRightParenthesis => "superscript right parenthesis",
SuperscriptsandSubscripts::SuperscriptLatinSmallLetterN => "superscript latin small letter n",
SuperscriptsandSubscripts::SubscriptZero => "subscript zero",
SuperscriptsandSubscripts::SubscriptOne => "subscript one",
SuperscriptsandSubscripts::SubscriptTwo => "subscript two",
SuperscriptsandSubscripts::SubscriptThree => "subscript three",
SuperscriptsandSubscripts::SubscriptFour => "subscript four",
SuperscriptsandSubscripts::SubscriptFive => "subscript five",
SuperscriptsandSubscripts::SubscriptSix => "subscript six",
SuperscriptsandSubscripts::SubscriptSeven => "subscript seven",
SuperscriptsandSubscripts::SubscriptEight => "subscript eight",
SuperscriptsandSubscripts::SubscriptNine => "subscript nine",
SuperscriptsandSubscripts::SubscriptPlusSign => "subscript plus sign",
SuperscriptsandSubscripts::SubscriptMinus => "subscript minus",
SuperscriptsandSubscripts::SubscriptEqualsSign => "subscript equals sign",
SuperscriptsandSubscripts::SubscriptLeftParenthesis => "subscript left parenthesis",
SuperscriptsandSubscripts::SubscriptRightParenthesis => "subscript right parenthesis",
SuperscriptsandSubscripts::LatinSubscriptSmallLetterA => "latin subscript small letter a",
SuperscriptsandSubscripts::LatinSubscriptSmallLetterE => "latin subscript small letter e",
SuperscriptsandSubscripts::LatinSubscriptSmallLetterO => "latin subscript small letter o",
SuperscriptsandSubscripts::LatinSubscriptSmallLetterX => "latin subscript small letter x",
SuperscriptsandSubscripts::LatinSubscriptSmallLetterSchwa => "latin subscript small letter schwa",
SuperscriptsandSubscripts::LatinSubscriptSmallLetterH => "latin subscript small letter h",
SuperscriptsandSubscripts::LatinSubscriptSmallLetterK => "latin subscript small letter k",
SuperscriptsandSubscripts::LatinSubscriptSmallLetterL => "latin subscript small letter l",
SuperscriptsandSubscripts::LatinSubscriptSmallLetterM => "latin subscript small letter m",
SuperscriptsandSubscripts::LatinSubscriptSmallLetterN => "latin subscript small letter n",
SuperscriptsandSubscripts::LatinSubscriptSmallLetterP => "latin subscript small letter p",
SuperscriptsandSubscripts::LatinSubscriptSmallLetterS => "latin subscript small letter s",
SuperscriptsandSubscripts::LatinSubscriptSmallLetterT => "latin subscript small letter t",
}
}
}