use super::insert_unique;
use std::collections::HashMap;
use std::sync::OnceLock;
pub type NumeralRule = (&'static str, &'static str);
const NUMERAL_RULES: &[NumeralRule] = &[
("0", "\u{09e6}"),
("1", "\u{09e7}"),
("2", "\u{09e8}"),
("3", "\u{09e9}"),
("4", "\u{09ea}"),
("5", "\u{09eb}"),
("6", "\u{09ec}"),
("7", "\u{09ed}"),
("8", "\u{09ee}"),
("9", "\u{09ef}"),
];
pub fn bengali_digit(digit: char) -> Option<&'static str> {
match digit {
'0' => Some("\u{09e6}"),
'1' => Some("\u{09e7}"),
'2' => Some("\u{09e8}"),
'3' => Some("\u{09e9}"),
'4' => Some("\u{09ea}"),
'5' => Some("\u{09eb}"),
'6' => Some("\u{09ec}"),
'7' => Some("\u{09ed}"),
'8' => Some("\u{09ee}"),
'9' => Some("\u{09ef}"),
_ => None,
}
}
fn build_numerals() -> HashMap<&'static str, &'static str> {
let mut map = HashMap::with_capacity(NUMERAL_RULES.len());
for &(roman, bengali) in NUMERAL_RULES {
insert_unique(&mut map, "numeral", roman, bengali);
}
map
}
pub const fn numeral_rules() -> &'static [NumeralRule] {
NUMERAL_RULES
}
pub fn numerals_static() -> &'static HashMap<&'static str, &'static str> {
static INSTANCE: OnceLock<HashMap<&'static str, &'static str>> = OnceLock::new();
INSTANCE.get_or_init(build_numerals)
}
pub fn numerals() -> HashMap<&'static str, &'static str> {
numerals_static().clone()
}