use std::path::Path; use crate::{ common::{Codepoint, CodepointIter, UcdFile, UcdFileByCodepoint}, error::Error, }; /// A single row in the `NameAliases.txt` file. /// /// Note that there are multiple rows for some codepoint. Each row provides a /// new alias. #[derive(Clone, Debug, Default, Eq, PartialEq)] pub struct NameAlias { /// The codepoint corresponding to this row. pub codepoint: Codepoint, /// The alias. pub alias: String, /// The label of this alias. pub label: NameAliasLabel, } impl UcdFile for NameAlias { fn relative_file_path() -> &'static Path { Path::new("NameAliases.txt") } } impl UcdFileByCodepoint for NameAlias { fn codepoints(&self) -> CodepointIter { self.codepoint.into_iter() } } impl std::str::FromStr for NameAlias { type Err = Error; fn from_str(line: &str) -> Result { let re_parts = regex!( r"(?x) ^ (?P[A-Z0-9]+); \s* (?P[^;]+); \s* (?P