use serde_json::Value; use std::collections::HashMap; use std::collections::HashSet; use std::fs; use unic_langid_impl::subtags::{Language, Script}; use unic_langid_impl::CharacterDirection; use unic_langid_impl::LanguageIdentifier; fn langid_to_direction_map(path: &str) -> HashMap { let mut result = HashMap::new(); for entry in fs::read_dir(path).unwrap() { let entry = entry.unwrap(); let mut path = entry.path(); path.push("layout.json"); let contents = fs::read_to_string(path).expect("Something went wrong reading the file"); let v: Value = serde_json::from_str(&contents).unwrap(); let langid_key = v["main"].as_object().unwrap().keys().nth(0).unwrap(); if langid_key == "root" { continue; } let langid: LanguageIdentifier = langid_key.parse().unwrap(); let character_order = match v["main"][langid_key]["layout"]["orientation"]["characterOrder"] .as_str() .unwrap() { "right-to-left" => CharacterDirection::RTL, "left-to-right" => CharacterDirection::LTR, _ => unimplemented!("Encountered unknown directionality!"), }; result.insert(langid, character_order); } result } fn check_all_variants_rtl( map: &HashMap, lang: Option, script: Option