Skip to main content

icu_locale_core/extensions/private/
other.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
5impl_tinystr_subtag!(
6    /// A single item used in a list of [`Private`](super::Private) extensions.
7    ///
8    /// The subtag has to be an ASCII alphanumerical string no shorter than
9    /// one character and no longer than eight.
10    ///
11    /// # Examples
12    ///
13    /// ```
14    /// use icu::locale::extensions::private::Subtag;
15    ///
16    /// let subtag1: Subtag = "Foo".parse().expect("Failed to parse a Subtag.");
17    ///
18    /// assert_eq!(subtag1.as_str(), "foo");
19    /// ```
20    ///
21    /// Notice: This is different from the generic [`Subtag`](crate::subtags::Subtag)
22    /// which is between two and eight characters.
23    ///
24    /// ```
25    /// use icu::locale::extensions::private;
26    /// use icu::locale::subtags;
27    ///
28    /// let subtag: Result<private::Subtag, _> = "f".parse();
29    /// assert!(subtag.is_ok());
30    ///
31    /// let subtag: Result<subtags::Subtag, _> = "f".parse();
32    /// assert!(subtag.is_err());
33    /// ```
34    Subtag,
35    extensions::private,
36    subtag,
37    extensions_private_subtag,
38    1..=8,
39    s,
40    s.is_ascii_alphanumeric(),
41    s.to_ascii_lowercase(),
42    s.is_ascii_alphanumeric() && s.is_ascii_lowercase(),
43    InvalidExtension,
44    ["foo12"],
45    ["toolooong"],
46);