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 variant subtag (examples: `"macos"`, `"posix"`, `"1996"` etc.)
7 ///
8 /// [`Variant`] represents a Unicode base language code conformant to the
9 /// [`unicode_variant_id`] field of the Language and Locale Identifier.
10 ///
11 /// # Examples
12 ///
13 /// ```
14 /// use icu::locid::subtags::Variant;
15 ///
16 /// let variant: Variant =
17 /// "macos".parse().expect("Failed to parse a variant subtag.");
18 /// ```
19 ///
20 /// [`unicode_variant_id`]: https://unicode.org/reports/tr35/#unicode_variant_id
21 Variant,
22 subtags,
23 variant,
24 subtags_variant,
25 4..=8,
26 s,
27 s.is_ascii_alphanumeric() && (s.len() != 4 || s.all_bytes()[0].is_ascii_digit()),
28 s.to_ascii_lowercase(),
29 s.is_ascii_lowercase()
30 && s.is_ascii_alphanumeric()
31 && (s.len() != 4 || s.all_bytes()[0].is_ascii_digit()),
32 InvalidSubtag,
33 ["posix", "1996"],
34 ["yes"],
35);
36