]> git.proxmox.com Git - rustc.git/blob - vendor/icu_locid/src/extensions/unicode/key.rs
New upstream version 1.67.1+dfsg1
[rustc.git] / vendor / icu_locid / src / extensions / unicode / key.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
5 impl_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::Key,
21 extensions_unicode_key,
22 2..=2,
23 s,
24 s.all_bytes()[0].is_ascii_alphanumeric() && s.all_bytes()[1].is_ascii_alphabetic(),
25 s.to_ascii_lowercase(),
26 (s.all_bytes()[0].is_ascii_lowercase() || s.all_bytes()[0].is_ascii_digit())
27 && s.all_bytes()[1].is_ascii_lowercase(),
28 InvalidExtension,
29 ["ca", "8a"],
30 ["a", "a8", "abc"],
31 );