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 single item used in a list of [`Other`](super::Other) extensions.
7 ///
8 /// The subtag has to be an ASCII alphanumerical string no shorter than
9 /// two characters and no longer than eight.
10 ///
11 /// # Examples
12 ///
13 /// ```
14 /// use icu::locid::extensions::other::subtag;
15 ///
16 /// assert_eq!(subtag!("Foo").as_str(), "foo");
17 /// ```
18 Subtag,
19 extensions::other,
20 subtag,
21 extensions_other_subtag,
22 2..=8,
23 s,
24 s.is_ascii_alphanumeric(),
25 s.to_ascii_lowercase(),
26 s.is_ascii_alphanumeric() && s.is_ascii_lowercase(),
27 InvalidExtension,
28 ["foo12"],
29 ["y", "toolooong"],
30);
31
32impl Subtag {
33 pub(crate) const fn valid_key(v: &[u8]) -> bool {
34 2 <= v.len() && v.len() <= 8
35 }
36}
37