| 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 [`Fields`](super::Fields). |
| 7 | /// |
| 8 | /// The key has to be a two ASCII characters long, with the first |
| 9 | /// character being alphabetic, and the second being a number. |
| 10 | /// |
| 11 | /// # Examples |
| 12 | /// |
| 13 | /// ``` |
| 14 | /// use icu::locid::extensions::transform::Key; |
| 15 | /// |
| 16 | /// let key1: Key = "k0".parse().expect("Failed to parse a Key."); |
| 17 | /// |
| 18 | /// assert_eq!(key1.as_str(), "k0"); |
| 19 | /// ``` |
| 20 | Key, |
| 21 | extensions::transform, |
| 22 | key, |
| 23 | extensions_transform_key, |
| 24 | 2..=2, |
| 25 | s, |
| 26 | s.all_bytes()[0].is_ascii_alphabetic() && s.all_bytes()[1].is_ascii_digit(), |
| 27 | s.to_ascii_lowercase(), |
| 28 | s.all_bytes()[0].is_ascii_lowercase() && s.all_bytes()[1].is_ascii_digit(), |
| 29 | InvalidExtension, |
| 30 | ["k0" ], |
| 31 | ["" , "k" , "0k" , "k12" ], |
| 32 | ); |
| 33 | |