• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 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()
17     ///     .expect("Failed to parse a Subtag.");
18     ///
19     /// assert_eq!(subtag1.as_str(), "foo");
20     /// ```
21     ///
22     /// Notice: This is different from the generic [`Subtag`](crate::subtags::Subtag)
23     /// which is between two and eight characters.
24     ///
25     /// ```
26     /// use icu::locale::extensions::private;
27     /// use icu::locale::subtags;
28     ///
29     /// let subtag: Result<private::Subtag, _> = "f".parse();
30     /// assert!(subtag.is_ok());
31     ///
32     /// let subtag: Result<subtags::Subtag, _> = "f".parse();
33     /// assert!(subtag.is_err());
34     /// ```
35     Subtag,
36     extensions::private,
37     subtag,
38     extensions_private_subtag,
39     1..=8,
40     s,
41     s.is_ascii_alphanumeric(),
42     s.to_ascii_lowercase(),
43     s.is_ascii_alphanumeric() && s.is_ascii_lowercase(),
44     InvalidExtension,
45     ["foo12"],
46     ["toolooong"],
47 );
48