icu_locale_core/preferences/extensions/unicode/keywords/
currency.rs1use crate::preferences::extensions::unicode::errors::PreferencesParseError;
6use crate::preferences::extensions::unicode::struct_keyword;
7use crate::{extensions::unicode::Value, subtags::Subtag};
8use tinystr::TinyAsciiStr;
9
10struct_keyword!(
11 CurrencyType,
15 "cu",
16 TinyAsciiStr<3>,
17 |input: Value| {
18 if let Some(subtag) = input.into_single_subtag() {
19 let ts = subtag.as_tinystr();
20 if ts.len() == 3 && ts.is_ascii_alphabetic() {
21 return Ok(Self(ts.resize()));
22 }
23 }
24 Err(PreferencesParseError::InvalidKeywordValue)
25 },
26 |input: CurrencyType| {
27 crate::extensions::unicode::Value::from_subtag(Some(
28 Subtag::from_tinystr_unvalidated(input.0.resize()),
29 ))
30 }
31);