icu_locale_core/preferences/extensions/unicode/keywords/numbering_system.rs
1// This file is part of ICU4X. For terms of use, please see the file
2// called LICENSE at the top level of the ICU4X source tree
3// (online at: https://github.com/unicode-org/icu4x/blob/main/LICENSE ).
4
5use crate::preferences::extensions::unicode::errors::PreferencesParseError;
6use crate::preferences::extensions::unicode::struct_keyword;
7use crate::{extensions::unicode::Value, subtags::Subtag};
8
9struct_keyword!(
10 /// A Unicode Number System Identifier defines a type of number system.
11 ///
12 /// The valid values are listed in [LDML](https://unicode.org/reports/tr35/#UnicodeNumberSystemIdentifier).
13 [Copy]
14 NumberingSystem,
15 "nu",
16 Subtag,
17 |input: &Value| {
18 input
19 .as_single_subtag()
20 .copied()
21 .map(Self)
22 .ok_or(PreferencesParseError::InvalidKeywordValue)
23 },
24 |input: &NumberingSystem| {
25 Value::from_subtag(Some(input.0))
26 }
27);