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
5impl_tinystr_subtag!(
6 /// A key used in a list of [`Keywords`](super::Keywords).
7 ///
8 /// The key has to be a two ASCII alphanumerical characters long, with the first
9 /// character being alphanumeric, and the second being alphabetic.
10 ///
11 ///
12 /// # Examples
13 ///
14 /// ```
15 /// use icu::locid::extensions::unicode::Key;
16 ///
17 /// assert!("ca".parse::<Key>().is_ok());
18 /// ```
19 Key,
20 extensions::unicode,
21 key,
22 extensions_unicode_key,
23 2..=2,
24 s,
25 s.all_bytes()[0].is_ascii_alphanumeric() && s.all_bytes()[1].is_ascii_alphabetic(),
26 s.to_ascii_lowercase(),
27 (s.all_bytes()[0].is_ascii_lowercase() || s.all_bytes()[0].is_ascii_digit())
28 && s.all_bytes()[1].is_ascii_lowercase(),
29 InvalidExtension,
30 ["ca", "8a"],
31 ["a", "a8", "abc"],
32);
33