summaryrefslogtreecommitdiffstats
path: root/vendor/icu_locid/src
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-06-07 05:48:48 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-06-07 05:48:48 +0000
commitef24de24a82fe681581cc130f342363c47c0969a (patch)
tree0d494f7e1a38b95c92426f58fe6eaa877303a86c /vendor/icu_locid/src
parentReleasing progress-linux version 1.74.1+dfsg1-1~progress7.99u1. (diff)
downloadrustc-ef24de24a82fe681581cc130f342363c47c0969a.tar.xz
rustc-ef24de24a82fe681581cc130f342363c47c0969a.zip
Merging upstream version 1.75.0+dfsg1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'vendor/icu_locid/src')
-rw-r--r--vendor/icu_locid/src/extensions/other/mod.rs14
-rw-r--r--vendor/icu_locid/src/extensions/other/subtag.rs5
-rw-r--r--vendor/icu_locid/src/extensions/private/mod.rs16
-rw-r--r--vendor/icu_locid/src/extensions/private/other.rs3
-rw-r--r--vendor/icu_locid/src/extensions/transform/fields.rs23
-rw-r--r--vendor/icu_locid/src/extensions/transform/key.rs3
-rw-r--r--vendor/icu_locid/src/extensions/transform/mod.rs29
-rw-r--r--vendor/icu_locid/src/extensions/transform/value.rs20
-rw-r--r--vendor/icu_locid/src/extensions/unicode/attribute.rs6
-rw-r--r--vendor/icu_locid/src/extensions/unicode/attributes.rs12
-rw-r--r--vendor/icu_locid/src/extensions/unicode/key.rs3
-rw-r--r--vendor/icu_locid/src/extensions/unicode/keywords.rs40
-rw-r--r--vendor/icu_locid/src/extensions/unicode/mod.rs42
-rw-r--r--vendor/icu_locid/src/extensions/unicode/value.rs24
-rw-r--r--vendor/icu_locid/src/helpers.rs127
-rw-r--r--vendor/icu_locid/src/langid.rs26
-rw-r--r--vendor/icu_locid/src/lib.rs4
-rw-r--r--vendor/icu_locid/src/locale.rs28
-rw-r--r--vendor/icu_locid/src/parser/langid.rs6
-rw-r--r--vendor/icu_locid/src/subtags/language.rs7
-rw-r--r--vendor/icu_locid/src/subtags/mod.rs12
-rw-r--r--vendor/icu_locid/src/subtags/region.rs5
-rw-r--r--vendor/icu_locid/src/subtags/script.rs5
-rw-r--r--vendor/icu_locid/src/subtags/variant.rs5
-rw-r--r--vendor/icu_locid/src/subtags/variants.rs16
-rw-r--r--vendor/icu_locid/src/zerovec.rs4
26 files changed, 273 insertions, 212 deletions
diff --git a/vendor/icu_locid/src/extensions/other/mod.rs b/vendor/icu_locid/src/extensions/other/mod.rs
index 44d5c9cf8..933128739 100644
--- a/vendor/icu_locid/src/extensions/other/mod.rs
+++ b/vendor/icu_locid/src/extensions/other/mod.rs
@@ -21,10 +21,12 @@
mod subtag;
+use crate::helpers::ShortSlice;
use crate::parser::ParserError;
use crate::parser::SubtagIterator;
use alloc::vec::Vec;
-pub use subtag::Subtag;
+#[doc(inline)]
+pub use subtag::{subtag, Subtag};
/// A list of [`Other Use Extensions`] as defined in [`Unicode Locale
/// Identifier`] specification.
@@ -49,7 +51,7 @@ pub use subtag::Subtag;
#[derive(Clone, PartialEq, Eq, Debug, Default, Hash, PartialOrd, Ord)]
pub struct Other {
ext: u8,
- keys: Vec<Subtag>,
+ keys: ShortSlice<Subtag>,
}
impl Other {
@@ -71,6 +73,10 @@ impl Other {
/// assert_eq!(&other.to_string(), "a-foo-bar");
/// ```
pub fn from_vec_unchecked(ext: u8, keys: Vec<Subtag>) -> Self {
+ Self::from_short_slice_unchecked(ext, keys.into())
+ }
+
+ pub(crate) fn from_short_slice_unchecked(ext: u8, keys: ShortSlice<Subtag>) -> Self {
assert!(ext.is_ascii_alphabetic());
Self { ext, keys }
}
@@ -78,7 +84,7 @@ impl Other {
pub(crate) fn try_from_iter(ext: u8, iter: &mut SubtagIterator) -> Result<Self, ParserError> {
debug_assert!(ext.is_ascii_alphabetic());
- let mut keys = Vec::new();
+ let mut keys = ShortSlice::new();
while let Some(subtag) = iter.peek() {
if !Subtag::valid_key(subtag) {
break;
@@ -89,7 +95,7 @@ impl Other {
iter.next();
}
- Ok(Self::from_vec_unchecked(ext, keys))
+ Ok(Self::from_short_slice_unchecked(ext, keys))
}
/// Gets the tag character for this extension as a &str.
diff --git a/vendor/icu_locid/src/extensions/other/subtag.rs b/vendor/icu_locid/src/extensions/other/subtag.rs
index ad4d6a0f2..03be56940 100644
--- a/vendor/icu_locid/src/extensions/other/subtag.rs
+++ b/vendor/icu_locid/src/extensions/other/subtag.rs
@@ -11,12 +11,13 @@ impl_tinystr_subtag!(
/// # Examples
///
/// ```
- /// use icu::locid::extensions_other_subtag as subtag;
+ /// use icu::locid::extensions::other::subtag;
///
/// assert_eq!(subtag!("Foo").as_str(), "foo");
/// ```
Subtag,
- extensions::other::Subtag,
+ extensions::other,
+ subtag,
extensions_other_subtag,
2..=8,
s,
diff --git a/vendor/icu_locid/src/extensions/private/mod.rs b/vendor/icu_locid/src/extensions/private/mod.rs
index 8382d166f..161d47f56 100644
--- a/vendor/icu_locid/src/extensions/private/mod.rs
+++ b/vendor/icu_locid/src/extensions/private/mod.rs
@@ -13,7 +13,7 @@
//! # Examples
//!
//! ```
-//! use icu::locid::extensions_private_subtag as subtag;
+//! use icu::locid::extensions::private::subtag;
//! use icu::locid::{locale, Locale};
//!
//! let mut loc: Locale = "en-US-x-foo-faa".parse().expect("Parsing failed.");
@@ -32,8 +32,10 @@ mod other;
use alloc::vec::Vec;
use core::ops::Deref;
-pub use other::Subtag;
+#[doc(inline)]
+pub use other::{subtag, Subtag};
+use crate::helpers::ShortSlice;
use crate::parser::ParserError;
use crate::parser::SubtagIterator;
@@ -58,7 +60,7 @@ use crate::parser::SubtagIterator;
/// [`Private Use Extensions`]: https://unicode.org/reports/tr35/#pu_extensions
/// [`Unicode Locale Identifier`]: https://unicode.org/reports/tr35/#Unicode_locale_identifier
#[derive(Clone, PartialEq, Eq, Debug, Default, Hash, PartialOrd, Ord)]
-pub struct Private(Vec<Subtag>);
+pub struct Private(ShortSlice<Subtag>);
impl Private {
/// Returns a new empty list of private-use extensions. Same as [`default()`](Default::default()), but is `const`.
@@ -72,7 +74,7 @@ impl Private {
/// ```
#[inline]
pub const fn new() -> Self {
- Self(Vec::new())
+ Self(ShortSlice::new())
}
/// A constructor which takes a pre-sorted list of [`Subtag`].
@@ -89,7 +91,7 @@ impl Private {
/// assert_eq!(&private.to_string(), "x-foo-bar");
/// ```
pub fn from_vec_unchecked(input: Vec<Subtag>) -> Self {
- Self(input)
+ Self(input.into())
}
/// Empties the [`Private`] list.
@@ -116,9 +118,9 @@ impl Private {
pub(crate) fn try_from_iter(iter: &mut SubtagIterator) -> Result<Self, ParserError> {
let keys = iter
.map(Subtag::try_from_bytes)
- .collect::<Result<Vec<_>, _>>()?;
+ .collect::<Result<ShortSlice<_>, _>>()?;
- Ok(Self::from_vec_unchecked(keys))
+ Ok(Self(keys))
}
pub(crate) fn for_each_subtag_str<E, F>(&self, f: &mut F) -> Result<(), E>
diff --git a/vendor/icu_locid/src/extensions/private/other.rs b/vendor/icu_locid/src/extensions/private/other.rs
index a91e12855..810ffa2f4 100644
--- a/vendor/icu_locid/src/extensions/private/other.rs
+++ b/vendor/icu_locid/src/extensions/private/other.rs
@@ -18,7 +18,8 @@ impl_tinystr_subtag!(
/// assert_eq!(subtag1.as_str(), "foo");
/// ```
Subtag,
- extensions::private::Subtag,
+ extensions::private,
+ subtag,
extensions_private_subtag,
1..=8,
s,
diff --git a/vendor/icu_locid/src/extensions/transform/fields.rs b/vendor/icu_locid/src/extensions/transform/fields.rs
index f08581a87..2f12de9d1 100644
--- a/vendor/icu_locid/src/extensions/transform/fields.rs
+++ b/vendor/icu_locid/src/extensions/transform/fields.rs
@@ -24,11 +24,10 @@ use super::Value;
/// # Examples
///
/// ```
-/// use icu::locid::extensions::transform::{Fields, Key, Value};
-/// use icu::locid::extensions_transform_key as key;
+/// use icu::locid::extensions::transform::{key, Fields, Key, Value};
///
/// let value = "hybrid".parse::<Value>().expect("Failed to parse a Value.");
-/// let fields = vec![(key!("h0"), value)].into_iter().collect::<Fields>();
+/// let fields = [(key!("h0"), value)].into_iter().collect::<Fields>();
///
/// assert_eq!(&fields.to_string(), "h0-hybrid");
/// ```
@@ -76,11 +75,10 @@ impl Fields {
/// # Examples
///
/// ```
- /// use icu::locid::extensions::transform::{Fields, Value};
- /// use icu::locid::extensions_transform_key as key;
+ /// use icu::locid::extensions::transform::{key, Fields, Value};
///
/// let value = "hybrid".parse::<Value>().expect("Failed to parse a Value.");
- /// let mut fields = vec![(key!("h0"), value)].into_iter().collect::<Fields>();
+ /// let mut fields = [(key!("h0"), value)].into_iter().collect::<Fields>();
///
/// assert_eq!(&fields.to_string(), "h0-hybrid");
///
@@ -102,7 +100,7 @@ impl Fields {
///
/// let key: Key = "h0".parse().expect("Failed to parse a Key.");
/// let value: Value = "hybrid".parse().expect("Failed to parse a Value.");
- /// let mut fields: Fields = vec![(key, value)].into_iter().collect();
+ /// let mut fields = [(key, value)].into_iter().collect::<Fields>();
///
/// let key: Key = "h0".parse().expect("Failed to parse a Key.");
/// assert!(&fields.contains_key(&key));
@@ -121,11 +119,10 @@ impl Fields {
/// # Examples
///
/// ```
- /// use icu::locid::extensions::transform::{Fields, Key, Value};
- /// use icu::locid::extensions_transform_key as key;
+ /// use icu::locid::extensions::transform::{key, Fields, Key, Value};
///
/// let value = "hybrid".parse::<Value>().unwrap();
- /// let fields = vec![(key!("h0"), value.clone())]
+ /// let fields = [(key!("h0"), value.clone())]
/// .into_iter()
/// .collect::<Fields>();
///
@@ -144,9 +141,7 @@ impl Fields {
/// # Examples
///
/// ```
- /// use icu::locid::extensions::transform::Key;
- /// use icu::locid::extensions::transform::Value;
- /// use icu::locid::extensions_transform_key as key;
+ /// use icu::locid::extensions::transform::{key, Key, Value};
/// use icu::locid::Locale;
///
/// let lower = "lower".parse::<Value>().expect("valid extension subtag");
@@ -169,7 +164,7 @@ impl Fields {
/// # Examples
///
/// ```
- /// use icu::locid::extensions_transform_key as key;
+ /// use icu::locid::extensions::transform::key;
/// use icu::locid::Locale;
///
/// let mut loc: Locale = "und-t-h0-hybrid-d0-hex-m0-xml".parse().unwrap();
diff --git a/vendor/icu_locid/src/extensions/transform/key.rs b/vendor/icu_locid/src/extensions/transform/key.rs
index 5400988a1..afdb31d76 100644
--- a/vendor/icu_locid/src/extensions/transform/key.rs
+++ b/vendor/icu_locid/src/extensions/transform/key.rs
@@ -18,7 +18,8 @@ impl_tinystr_subtag!(
/// assert_eq!(key1.as_str(), "k0");
/// ```
Key,
- extensions::transform::Key,
+ extensions::transform,
+ key,
extensions_transform_key,
2..=2,
s,
diff --git a/vendor/icu_locid/src/extensions/transform/mod.rs b/vendor/icu_locid/src/extensions/transform/mod.rs
index 7b97d87f6..4156c5910 100644
--- a/vendor/icu_locid/src/extensions/transform/mod.rs
+++ b/vendor/icu_locid/src/extensions/transform/mod.rs
@@ -35,14 +35,15 @@ mod key;
mod value;
pub use fields::Fields;
-pub use key::Key;
+#[doc(inline)]
+pub use key::{key, Key};
pub use value::Value;
+use crate::helpers::ShortSlice;
use crate::parser::SubtagIterator;
use crate::parser::{parse_language_identifier_from_iter, ParserError, ParserMode};
use crate::subtags::Language;
use crate::LanguageIdentifier;
-use alloc::vec;
use litemap::LiteMap;
/// A list of [`Unicode BCP47 T Extensions`] as defined in [`Unicode Locale
@@ -144,21 +145,24 @@ impl Transform {
}
let mut current_tkey = None;
- let mut current_tvalue = vec![];
+ let mut current_tvalue = ShortSlice::new();
+ let mut has_current_tvalue = false;
while let Some(subtag) = iter.peek() {
if let Some(tkey) = current_tkey {
if let Ok(val) = Value::parse_subtag(subtag) {
- current_tvalue.push(val);
+ has_current_tvalue = true;
+ if let Some(val) = val {
+ current_tvalue.push(val);
+ }
} else {
- if current_tvalue.is_empty() {
+ if !has_current_tvalue {
return Err(ParserError::InvalidExtension);
}
- tfields.try_insert(
- tkey,
- Value::from_vec_unchecked(current_tvalue.drain(..).flatten().collect()),
- );
+ tfields.try_insert(tkey, Value::from_short_slice_unchecked(current_tvalue));
current_tkey = None;
+ current_tvalue = ShortSlice::new();
+ has_current_tvalue = false;
continue;
}
} else if let Ok(tkey) = Key::try_from_bytes(subtag) {
@@ -171,13 +175,10 @@ impl Transform {
}
if let Some(tkey) = current_tkey {
- if current_tvalue.is_empty() {
+ if !has_current_tvalue {
return Err(ParserError::InvalidExtension);
}
- tfields.try_insert(
- tkey,
- Value::from_vec_unchecked(current_tvalue.into_iter().flatten().collect()),
- );
+ tfields.try_insert(tkey, Value::from_short_slice_unchecked(current_tvalue));
}
Ok(Self {
diff --git a/vendor/icu_locid/src/extensions/transform/value.rs b/vendor/icu_locid/src/extensions/transform/value.rs
index f908b0208..798e84793 100644
--- a/vendor/icu_locid/src/extensions/transform/value.rs
+++ b/vendor/icu_locid/src/extensions/transform/value.rs
@@ -2,9 +2,8 @@
// called LICENSE at the top level of the ICU4X source tree
// (online at: https://github.com/unicode-org/icu4x/blob/main/LICENSE ).
+use crate::helpers::ShortSlice;
use crate::parser::{ParserError, SubtagIterator};
-use alloc::vec;
-use alloc::vec::Vec;
use core::ops::RangeInclusive;
use core::str::FromStr;
use tinystr::TinyAsciiStr;
@@ -28,7 +27,7 @@ use tinystr::TinyAsciiStr;
/// "no".parse::<Value>().expect_err("Invalid Value.");
/// ```
#[derive(Debug, PartialEq, Eq, Clone, Hash, PartialOrd, Ord, Default)]
-pub struct Value(Vec<TinyAsciiStr<{ *TYPE_LENGTH.end() }>>);
+pub struct Value(ShortSlice<TinyAsciiStr<{ *TYPE_LENGTH.end() }>>);
const TYPE_LENGTH: RangeInclusive<usize> = 3..=8;
const TRUE_TVALUE: TinyAsciiStr<8> = tinystr::tinystr!(8, "true");
@@ -45,7 +44,7 @@ impl Value {
/// let value = Value::try_from_bytes(b"hybrid").expect("Parsing failed.");
/// ```
pub fn try_from_bytes(input: &[u8]) -> Result<Self, ParserError> {
- let mut v = vec![];
+ let mut v = ShortSlice::default();
let mut has_value = false;
for subtag in SubtagIterator::new(input) {
@@ -66,12 +65,14 @@ impl Value {
Ok(Self(v))
}
- pub(crate) fn from_vec_unchecked(input: Vec<TinyAsciiStr<{ *TYPE_LENGTH.end() }>>) -> Self {
+ pub(crate) fn from_short_slice_unchecked(
+ input: ShortSlice<TinyAsciiStr<{ *TYPE_LENGTH.end() }>>,
+ ) -> Self {
Self(input)
}
pub(crate) fn is_type_subtag(t: &[u8]) -> bool {
- TYPE_LENGTH.contains(&t.len()) && !t.iter().any(|c: &u8| !c.is_ascii_alphanumeric())
+ TYPE_LENGTH.contains(&t.len()) && t.iter().all(u8::is_ascii_alphanumeric)
}
pub(crate) fn parse_subtag(
@@ -122,9 +123,12 @@ fn test_writeable() {
let foobar = "foobar".parse().unwrap();
assert_writeable_eq!(Value::default(), "true");
- assert_writeable_eq!(Value::from_vec_unchecked(vec![hybrid]), "hybrid");
assert_writeable_eq!(
- Value::from_vec_unchecked(vec![hybrid, foobar]),
+ Value::from_short_slice_unchecked(vec![hybrid].into()),
+ "hybrid"
+ );
+ assert_writeable_eq!(
+ Value::from_short_slice_unchecked(vec![hybrid, foobar].into()),
"hybrid-foobar"
);
}
diff --git a/vendor/icu_locid/src/extensions/unicode/attribute.rs b/vendor/icu_locid/src/extensions/unicode/attribute.rs
index ba4b70924..f6fc53e05 100644
--- a/vendor/icu_locid/src/extensions/unicode/attribute.rs
+++ b/vendor/icu_locid/src/extensions/unicode/attribute.rs
@@ -12,8 +12,7 @@ impl_tinystr_subtag!(
/// # Examples
///
/// ```
- /// use icu::locid::extensions::unicode::Attribute;
- /// use icu::locid::extensions_unicode_attribute as attribute;
+ /// use icu::locid::extensions::unicode::{attribute, Attribute};
///
/// let attr: Attribute =
/// "buddhist".parse().expect("Failed to parse an Attribute.");
@@ -21,7 +20,8 @@ impl_tinystr_subtag!(
/// assert_eq!(attr, attribute!("buddhist"));
/// ```
Attribute,
- extensions::unicode::Attribute,
+ extensions::unicode,
+ attribute,
extensions_unicode_attribute,
3..=8,
s,
diff --git a/vendor/icu_locid/src/extensions/unicode/attributes.rs b/vendor/icu_locid/src/extensions/unicode/attributes.rs
index e58fb04da..1cdaded30 100644
--- a/vendor/icu_locid/src/extensions/unicode/attributes.rs
+++ b/vendor/icu_locid/src/extensions/unicode/attributes.rs
@@ -4,6 +4,7 @@
use super::Attribute;
+use crate::helpers::ShortSlice;
use alloc::vec::Vec;
use core::ops::Deref;
@@ -30,7 +31,7 @@ use core::ops::Deref;
/// assert_eq!(attributes.to_string(), "foobar-testing");
/// ```
#[derive(Default, Debug, PartialEq, Eq, Clone, Hash, PartialOrd, Ord)]
-pub struct Attributes(Vec<Attribute>);
+pub struct Attributes(ShortSlice<Attribute>);
impl Attributes {
/// Returns a new empty set of attributes. Same as [`default()`](Default::default()), but is `const`.
@@ -44,7 +45,7 @@ impl Attributes {
/// ```
#[inline]
pub const fn new() -> Self {
- Self(Vec::new())
+ Self(ShortSlice::new())
}
/// A constructor which takes a pre-sorted list of [`Attribute`] elements.
@@ -68,6 +69,10 @@ impl Attributes {
/// for the caller to use [`binary_search`](slice::binary_search) instead of [`sort`](slice::sort)
/// and [`dedup`](Vec::dedup()).
pub fn from_vec_unchecked(input: Vec<Attribute>) -> Self {
+ Self(input.into())
+ }
+
+ pub(crate) fn from_short_slice_unchecked(input: ShortSlice<Attribute>) -> Self {
Self(input)
}
@@ -78,8 +83,7 @@ impl Attributes {
/// # Examples
///
/// ```
- /// use icu::locid::extensions::unicode::{Attribute, Attributes};
- /// use icu::locid::extensions_unicode_attribute as attribute;
+ /// use icu::locid::extensions::unicode::{attribute, Attribute, Attributes};
/// use writeable::assert_writeable_eq;
///
/// let mut attributes = Attributes::from_vec_unchecked(vec![
diff --git a/vendor/icu_locid/src/extensions/unicode/key.rs b/vendor/icu_locid/src/extensions/unicode/key.rs
index bdfdd4e5c..e008ffd5a 100644
--- a/vendor/icu_locid/src/extensions/unicode/key.rs
+++ b/vendor/icu_locid/src/extensions/unicode/key.rs
@@ -17,7 +17,8 @@ impl_tinystr_subtag!(
/// assert!("ca".parse::<Key>().is_ok());
/// ```
Key,
- extensions::unicode::Key,
+ extensions::unicode,
+ key,
extensions_unicode_key,
2..=2,
s,
diff --git a/vendor/icu_locid/src/extensions/unicode/keywords.rs b/vendor/icu_locid/src/extensions/unicode/keywords.rs
index 4e2fbae9a..c2839fa44 100644
--- a/vendor/icu_locid/src/extensions/unicode/keywords.rs
+++ b/vendor/icu_locid/src/extensions/unicode/keywords.rs
@@ -13,7 +13,7 @@ use crate::helpers::ShortSlice;
use crate::ordering::SubtagOrderingResult;
/// A list of [`Key`]-[`Value`] pairs representing functional information
-/// about locale's internationnalization preferences.
+/// about locale's internationalization preferences.
///
/// Here are examples of fields used in Unicode:
/// - `hc` - Hour Cycle (`h11`, `h12`, `h23`, `h24`)
@@ -30,11 +30,11 @@ use crate::ordering::SubtagOrderingResult;
///
/// ```
/// use icu::locid::{
-/// extensions::unicode::Keywords, extensions_unicode_key as key,
-/// extensions_unicode_value as value, locale,
+/// extensions::unicode::{key, value, Keywords},
+/// locale,
/// };
///
-/// let keywords = vec![(key!("hc"), value!("h23"))]
+/// let keywords = [(key!("hc"), value!("h23"))]
/// .into_iter()
/// .collect::<Keywords>();
///
@@ -45,7 +45,7 @@ use crate::ordering::SubtagOrderingResult;
///
/// ```
/// use icu::locid::{
-/// extensions_unicode_key as key, extensions_unicode_value as value,
+/// extensions::unicode::{key, value},
/// Locale,
/// };
///
@@ -116,12 +116,9 @@ impl Keywords {
/// # Examples
///
/// ```
- /// use icu::locid::{
- /// extensions::unicode::Keywords, extensions_unicode_key as key,
- /// extensions_unicode_value as value,
- /// };
+ /// use icu::locid::extensions::unicode::{key, value, Keywords};
///
- /// let keywords = vec![(key!("ca"), value!("gregory"))]
+ /// let keywords = [(key!("ca"), value!("gregory"))]
/// .into_iter()
/// .collect::<Keywords>();
///
@@ -141,12 +138,9 @@ impl Keywords {
/// # Examples
///
/// ```
- /// use icu::locid::{
- /// extensions::unicode::Keywords, extensions_unicode_key as key,
- /// extensions_unicode_value as value,
- /// };
+ /// use icu::locid::extensions::unicode::{key, value, Keywords};
///
- /// let keywords = vec![(key!("ca"), value!("buddhist"))]
+ /// let keywords = [(key!("ca"), value!("buddhist"))]
/// .into_iter()
/// .collect::<Keywords>();
///
@@ -167,12 +161,9 @@ impl Keywords {
/// # Examples
///
/// ```
- /// use icu::locid::{
- /// extensions::unicode::Keywords, extensions_unicode_key as key,
- /// extensions_unicode_value as value,
- /// };
+ /// use icu::locid::extensions::unicode::{key, value, Keywords};
///
- /// let mut keywords = vec![(key!("ca"), value!("buddhist"))]
+ /// let mut keywords = [(key!("ca"), value!("buddhist"))]
/// .into_iter()
/// .collect::<Keywords>();
///
@@ -196,10 +187,8 @@ impl Keywords {
/// ```
/// use icu::locid::extensions::unicode::Key;
/// use icu::locid::extensions::unicode::Value;
+ /// use icu::locid::extensions::unicode::{key, value};
/// use icu::locid::Locale;
- /// use icu::locid::{
- /// extensions_unicode_key as key, extensions_unicode_value as value,
- /// };
///
/// let mut loc: Locale = "und-u-hello-ca-buddhist-hc-h12"
/// .parse()
@@ -222,8 +211,7 @@ impl Keywords {
/// # Examples
///
/// ```
- /// use icu::locid::extensions::unicode::Key;
- /// use icu::locid::extensions_unicode_key as key;
+ /// use icu::locid::extensions::unicode::{key, Key};
/// use icu::locid::Locale;
///
/// let mut loc: Locale = "und-u-hello-ca-buddhist-hc-h12"
@@ -258,7 +246,7 @@ impl Keywords {
/// # Examples
///
/// ```
- /// use icu::locid::extensions_unicode_key as key;
+ /// use icu::locid::extensions::unicode::key;
/// use icu::locid::Locale;
///
/// let mut loc: Locale = "und-u-ca-buddhist-hc-h12-ms-metric".parse().unwrap();
diff --git a/vendor/icu_locid/src/extensions/unicode/mod.rs b/vendor/icu_locid/src/extensions/unicode/mod.rs
index 687a8c383..95f1a2d78 100644
--- a/vendor/icu_locid/src/extensions/unicode/mod.rs
+++ b/vendor/icu_locid/src/extensions/unicode/mod.rs
@@ -11,12 +11,8 @@
//! # Examples
//!
//! ```
+//! use icu::locid::extensions::unicode::{attribute, key, value, Unicode};
//! use icu::locid::Locale;
-//! use icu::locid::{
-//! extensions::unicode::Unicode,
-//! extensions_unicode_attribute as attribute,
-//! extensions_unicode_key as key, extensions_unicode_value as value,
-//! };
//!
//! let loc: Locale = "en-US-u-foobar-hc-h12".parse().expect("Parsing failed.");
//!
@@ -36,13 +32,16 @@ mod key;
mod keywords;
mod value;
-use alloc::vec;
-pub use attribute::Attribute;
+#[doc(inline)]
+pub use attribute::{attribute, Attribute};
pub use attributes::Attributes;
-pub use key::Key;
+#[doc(inline)]
+pub use key::{key, Key};
pub use keywords::Keywords;
-pub use value::Value;
+#[doc(inline)]
+pub use value::{value, Value};
+use crate::helpers::ShortSlice;
use crate::parser::ParserError;
use crate::parser::SubtagIterator;
use litemap::LiteMap;
@@ -63,10 +62,8 @@ use litemap::LiteMap;
/// # Examples
///
/// ```
+/// use icu::locid::extensions::unicode::{key, value};
/// use icu::locid::Locale;
-/// use icu::locid::{
-/// extensions_unicode_key as key, extensions_unicode_value as value,
-/// };
///
/// let loc: Locale =
/// "de-u-hc-h12-ca-buddhist".parse().expect("Parsing failed.");
@@ -138,11 +135,7 @@ impl Unicode {
}
pub(crate) fn try_from_iter(iter: &mut SubtagIterator) -> Result<Self, ParserError> {
- let mut attributes = vec![];
- let mut keywords = LiteMap::new();
-
- let mut current_keyword = None;
- let mut current_type = vec![];
+ let mut attributes = ShortSlice::new();
while let Some(subtag) = iter.peek() {
if let Ok(attr) = Attribute::try_from_bytes(subtag) {
@@ -155,17 +148,22 @@ impl Unicode {
iter.next();
}
+ let mut keywords = LiteMap::new();
+
+ let mut current_keyword = None;
+ let mut current_value = ShortSlice::new();
+
while let Some(subtag) = iter.peek() {
let slen = subtag.len();
if slen == 2 {
if let Some(kw) = current_keyword.take() {
- keywords.try_insert(kw, Value::from_vec_unchecked(current_type));
- current_type = vec![];
+ keywords.try_insert(kw, Value::from_short_slice_unchecked(current_value));
+ current_value = ShortSlice::new();
}
current_keyword = Some(Key::try_from_bytes(subtag)?);
} else if current_keyword.is_some() {
match Value::parse_subtag(subtag) {
- Ok(Some(t)) => current_type.push(t),
+ Ok(Some(t)) => current_value.push(t),
Ok(None) => {}
Err(_) => break,
}
@@ -176,7 +174,7 @@ impl Unicode {
}
if let Some(kw) = current_keyword.take() {
- keywords.try_insert(kw, Value::from_vec_unchecked(current_type));
+ keywords.try_insert(kw, Value::from_short_slice_unchecked(current_value));
}
// Ensure we've defined at least one attribute or keyword
@@ -186,7 +184,7 @@ impl Unicode {
Ok(Self {
keywords: keywords.into(),
- attributes: Attributes::from_vec_unchecked(attributes),
+ attributes: Attributes::from_short_slice_unchecked(attributes),
})
}
diff --git a/vendor/icu_locid/src/extensions/unicode/value.rs b/vendor/icu_locid/src/extensions/unicode/value.rs
index f1b2402de..d935656a9 100644
--- a/vendor/icu_locid/src/extensions/unicode/value.rs
+++ b/vendor/icu_locid/src/extensions/unicode/value.rs
@@ -4,7 +4,6 @@
use crate::helpers::ShortSlice;
use crate::parser::{ParserError, SubtagIterator};
-use alloc::vec::Vec;
use core::ops::RangeInclusive;
use core::str::FromStr;
use tinystr::TinyAsciiStr;
@@ -20,9 +19,7 @@ use tinystr::TinyAsciiStr;
/// # Examples
///
/// ```
-/// use icu::locid::{
-/// extensions::unicode::Value, extensions_unicode_value as value,
-/// };
+/// use icu::locid::extensions::unicode::{value, Value};
/// use writeable::assert_writeable_eq;
///
/// assert_writeable_eq!(value!("gregory"), "gregory");
@@ -52,7 +49,7 @@ impl Value {
/// Value::try_from_bytes(b"buddhist").expect("Parsing failed.");
/// ```
pub fn try_from_bytes(input: &[u8]) -> Result<Self, ParserError> {
- let mut v = Vec::new();
+ let mut v = ShortSlice::new();
if !input.is_empty() {
for subtag in SubtagIterator::new(input) {
@@ -62,7 +59,7 @@ impl Value {
}
}
}
- Ok(Self(v.into()))
+ Ok(Self(v))
}
/// Const constructor for when the value contains only a single subtag.
@@ -85,7 +82,7 @@ impl Value {
#[doc(hidden)]
pub fn as_tinystr_slice(&self) -> &[TinyAsciiStr<8>] {
- self.0.as_slice()
+ &self.0
}
#[doc(hidden)]
@@ -105,8 +102,8 @@ impl Value {
}
}
- pub(crate) fn from_vec_unchecked(input: Vec<TinyAsciiStr<8>>) -> Self {
- Self(input.into())
+ pub(crate) fn from_short_slice_unchecked(input: ShortSlice<TinyAsciiStr<8>>) -> Self {
+ Self(input)
}
#[doc(hidden)]
@@ -140,7 +137,7 @@ impl Value {
where
F: FnMut(&str) -> Result<(), E>,
{
- self.0.as_slice().iter().map(|t| t.as_str()).try_for_each(f)
+ self.0.iter().map(TinyAsciiStr::as_str).try_for_each(f)
}
}
@@ -161,10 +158,8 @@ impl_writeable_for_subtag_list!(Value, "islamic", "civil");
/// # Examples
///
/// ```
+/// use icu::locid::extensions::unicode::{key, value};
/// use icu::locid::Locale;
-/// use icu::locid::{
-/// extensions_unicode_key as key, extensions_unicode_value as value,
-/// };
///
/// let loc: Locale = "de-u-ca-buddhist".parse().unwrap();
///
@@ -176,6 +171,7 @@ impl_writeable_for_subtag_list!(Value, "islamic", "civil");
///
/// [`Value`]: crate::extensions::unicode::Value
#[macro_export]
+#[doc(hidden)]
macro_rules! extensions_unicode_value {
($value:literal) => {{
// What we want:
@@ -196,3 +192,5 @@ macro_rules! extensions_unicode_value {
R
}};
}
+#[doc(inline)]
+pub use extensions_unicode_value as value;
diff --git a/vendor/icu_locid/src/helpers.rs b/vendor/icu_locid/src/helpers.rs
index 42b2b7286..d12435fbf 100644
--- a/vendor/icu_locid/src/helpers.rs
+++ b/vendor/icu_locid/src/helpers.rs
@@ -7,6 +7,7 @@ use core::iter::FromIterator;
use alloc::boxed::Box;
use alloc::vec;
use alloc::vec::Vec;
+use core::ops::{Deref, DerefMut};
use litemap::store::*;
/// Internal: A vector that supports no-allocation, constant values if length 0 or 1.
@@ -43,24 +44,6 @@ impl<T> ShortSlice<T> {
}
#[inline]
- pub fn as_slice(&self) -> &[T] {
- match self {
- ShortSlice::ZeroOne(None) => &[],
- ShortSlice::ZeroOne(Some(v)) => core::slice::from_ref(v),
- ShortSlice::Multi(v) => v,
- }
- }
-
- #[inline]
- pub fn as_mut_slice(&mut self) -> &mut [T] {
- match self {
- ShortSlice::ZeroOne(None) => &mut [],
- ShortSlice::ZeroOne(Some(v)) => core::slice::from_mut(v),
- ShortSlice::Multi(v) => v,
- }
- }
-
- #[inline]
pub const fn single(&self) -> Option<&T> {
match self {
ShortSlice::ZeroOne(Some(v)) => Some(v),
@@ -134,6 +117,43 @@ impl<T> ShortSlice<T> {
pub fn clear(&mut self) {
let _ = core::mem::replace(self, ShortSlice::ZeroOne(None));
}
+
+ pub fn retain<F>(&mut self, mut f: F)
+ where
+ F: FnMut(&T) -> bool,
+ {
+ *self = match core::mem::take(self) {
+ Self::ZeroOne(Some(one)) if f(&one) => Self::ZeroOne(Some(one)),
+ Self::ZeroOne(_) => Self::ZeroOne(None),
+ Self::Multi(slice) => {
+ let mut vec = slice.into_vec();
+ vec.retain(f);
+ Self::from(vec)
+ }
+ };
+ }
+}
+
+impl<T> Deref for ShortSlice<T> {
+ type Target = [T];
+
+ fn deref(&self) -> &Self::Target {
+ match self {
+ ShortSlice::ZeroOne(None) => &[],
+ ShortSlice::ZeroOne(Some(v)) => core::slice::from_ref(v),
+ ShortSlice::Multi(v) => v,
+ }
+ }
+}
+
+impl<T> DerefMut for ShortSlice<T> {
+ fn deref_mut(&mut self) -> &mut Self::Target {
+ match self {
+ ShortSlice::ZeroOne(None) => &mut [],
+ ShortSlice::ZeroOne(Some(v)) => core::slice::from_mut(v),
+ ShortSlice::Multi(v) => v,
+ }
+ }
}
impl<T> From<Vec<T>> for ShortSlice<T> {
@@ -155,7 +175,18 @@ impl<T> Default for ShortSlice<T> {
impl<T> FromIterator<T> for ShortSlice<T> {
fn from_iter<I: IntoIterator<Item = T>>(iter: I) -> Self {
- iter.into_iter().collect::<Vec<_>>().into()
+ let mut iter = iter.into_iter();
+ match (iter.next(), iter.next()) {
+ (Some(first), Some(second)) => {
+ // Size hint behaviour same as `Vec::extend` + 2
+ let mut vec = Vec::with_capacity(iter.size_hint().0.saturating_add(3));
+ vec.push(first);
+ vec.push(second);
+ vec.extend(iter);
+ Self::Multi(vec.into_boxed_slice())
+ }
+ (first, _) => Self::ZeroOne(first),
+ }
}
}
@@ -176,7 +207,7 @@ impl<K, V> Store<K, V> for ShortSlice<(K, V)> {
#[inline]
fn lm_get(&self, index: usize) -> Option<(&K, &V)> {
- self.as_slice().get(index).map(|elt| (&elt.0, &elt.1))
+ self.get(index).map(|elt| (&elt.0, &elt.1))
}
#[inline]
@@ -193,7 +224,7 @@ impl<K, V> Store<K, V> for ShortSlice<(K, V)> {
where
F: FnMut(&K) -> core::cmp::Ordering,
{
- self.as_slice().binary_search_by(|(k, _)| cmp(k))
+ self.binary_search_by(|(k, _)| cmp(k))
}
}
@@ -212,9 +243,7 @@ impl<K, V> StoreMut<K, V> for ShortSlice<(K, V)> {
fn lm_reserve(&mut self, _additional: usize) {}
fn lm_get_mut(&mut self, index: usize) -> Option<(&K, &mut V)> {
- self.as_mut_slice()
- .get_mut(index)
- .map(|elt| (&elt.0, &mut elt.1))
+ self.get_mut(index).map(|elt| (&elt.0, &mut elt.1))
}
fn lm_push(&mut self, key: K, value: V) {
@@ -232,6 +261,13 @@ impl<K, V> StoreMut<K, V> for ShortSlice<(K, V)> {
fn lm_clear(&mut self) {
self.clear();
}
+
+ fn lm_retain<F>(&mut self, mut predicate: F)
+ where
+ F: FnMut(&K, &V) -> bool,
+ {
+ self.retain(|(k, v)| predicate(k, v))
+ }
}
impl<'a, K: 'a, V: 'a> StoreIterable<'a, K, V> for ShortSlice<(K, V)> {
@@ -239,14 +275,14 @@ impl<'a, K: 'a, V: 'a> StoreIterable<'a, K, V> for ShortSlice<(K, V)> {
core::iter::Map<core::slice::Iter<'a, (K, V)>, for<'r> fn(&'r (K, V)) -> (&'r K, &'r V)>;
fn lm_iter(&'a self) -> Self::KeyValueIter {
- self.as_slice().iter().map(|elt| (&elt.0, &elt.1))
+ self.iter().map(|elt| (&elt.0, &elt.1))
}
}
impl<K, V> StoreFromIterator<K, V> for ShortSlice<(K, V)> {}
#[test]
-fn test_shortvec_impl() {
+fn test_short_slice_impl() {
litemap::testing::check_store::<ShortSlice<(u32, u64)>>();
}
@@ -254,8 +290,9 @@ macro_rules! impl_tinystr_subtag {
(
$(#[$doc:meta])*
$name:ident,
- $($full_name:ident)::+,
+ $($path:ident)::+,
$macro_name:ident,
+ $legacy_macro_name:ident,
$len_start:literal..=$len_end:literal,
$tinystr_ident:ident,
$validate:expr,
@@ -278,7 +315,7 @@ macro_rules! impl_tinystr_subtag {
/// # Examples
///
/// ```
- #[doc = concat!("use icu_locid::", stringify!($($full_name)::+), ";")]
+ #[doc = concat!("use icu_locid::", stringify!($($path::)+), stringify!($name), ";")]
///
#[doc = concat!("assert!(", stringify!($name), "::try_from_bytes(b", stringify!($good_example), ").is_ok());")]
#[doc = concat!("assert!(", stringify!($name), "::try_from_bytes(b", stringify!($bad_example), ").is_err());")]
@@ -349,6 +386,11 @@ macro_rules! impl_tinystr_subtag {
self.0.as_str()
}
+ #[doc(hidden)]
+ pub const fn into_tinystr(&self) -> tinystr::TinyAsciiStr<$len_end> {
+ self.0
+ }
+
/// Compare with BCP-47 bytes.
///
/// The return value is equivalent to what would happen if you first converted
@@ -389,7 +431,7 @@ macro_rules! impl_tinystr_subtag {
impl From<$name> for tinystr::TinyAsciiStr<$len_end> {
fn from(input: $name) -> Self {
- input.0
+ input.into_tinystr()
}
}
@@ -417,37 +459,40 @@ macro_rules! impl_tinystr_subtag {
/// Parsing errors don't have to be handled at runtime:
/// ```
/// assert_eq!(
- #[doc = concat!(" icu_locid::", stringify!($macro_name), "!(", stringify!($good_example) ,"),")]
- #[doc = concat!(" ", stringify!($good_example), ".parse::<icu_locid::", stringify!($($full_name)::+),">().unwrap()")]
+ #[doc = concat!(" icu_locid::", $(stringify!($path), "::",)+ stringify!($macro_name), "!(", stringify!($good_example) ,"),")]
+ #[doc = concat!(" ", stringify!($good_example), ".parse::<icu_locid::", $(stringify!($path), "::",)+ stringify!($name), ">().unwrap()")]
/// );
/// ```
///
/// Invalid input is a compile failure:
/// ```compile_fail,E0080
- #[doc = concat!("icu_locid::", stringify!($macro_name), "!(", stringify!($bad_example) ,");")]
+ #[doc = concat!("icu_locid::", $(stringify!($path), "::",)+ stringify!($macro_name), "!(", stringify!($bad_example) ,");")]
/// ```
///
- #[doc = concat!("[`", stringify!($name), "`]: crate::", stringify!($($full_name)::+))]
+ #[doc = concat!("[`", stringify!($name), "`]: crate::", $(stringify!($path), "::",)+ stringify!($name))]
#[macro_export]
- macro_rules! $macro_name {
+ #[doc(hidden)]
+ macro_rules! $legacy_macro_name {
($string:literal) => {{
- use $crate::$($full_name)::+;
+ use $crate::$($path ::)+ $name;
const R: $name =
match $name::try_from_bytes($string.as_bytes()) {
Ok(r) => r,
#[allow(clippy::panic)] // const context
- _ => panic!(concat!("Invalid ", stringify!($name), ": ", $string)),
+ _ => panic!(concat!("Invalid ", $(stringify!($path), "::",)+ stringify!($name), ": ", $string)),
};
R
}};
}
+ #[doc(inline)]
+ pub use $legacy_macro_name as $macro_name;
#[cfg(feature = "databake")]
impl databake::Bake for $name {
fn bake(&self, env: &databake::CrateEnv) -> databake::TokenStream {
env.insert("icu_locid");
let string = self.as_str();
- databake::quote! {::icu_locid::$macro_name!(#string) }
+ databake::quote! { icu_locid::$($path::)+ $macro_name!(#string) }
}
}
@@ -610,20 +655,20 @@ macro_rules! impl_writeable_for_each_subtag_str_no_test {
macro_rules! impl_writeable_for_subtag_list {
($type:tt, $sample1:literal, $sample2:literal) => {
- impl_writeable_for_each_subtag_str_no_test!($type, selff, selff.0.len() == 1 => alloc::borrow::Cow::Borrowed(selff.0.as_slice().get(0).unwrap().as_str()));
+ impl_writeable_for_each_subtag_str_no_test!($type, selff, selff.0.len() == 1 => alloc::borrow::Cow::Borrowed(selff.0.get(0).unwrap().as_str()));
#[test]
fn test_writeable() {
writeable::assert_writeable_eq!(&$type::default(), "");
writeable::assert_writeable_eq!(
- &$type::from_vec_unchecked(alloc::vec![$sample1.parse().unwrap()]),
+ &$type::from_short_slice_unchecked(alloc::vec![$sample1.parse().unwrap()].into()),
$sample1,
);
writeable::assert_writeable_eq!(
- &$type::from_vec_unchecked(vec![
+ &$type::from_short_slice_unchecked(vec![
$sample1.parse().unwrap(),
$sample2.parse().unwrap()
- ]),
+ ].into()),
core::concat!($sample1, "-", $sample2),
);
}
diff --git a/vendor/icu_locid/src/langid.rs b/vendor/icu_locid/src/langid.rs
index 78668bc0d..512959421 100644
--- a/vendor/icu_locid/src/langid.rs
+++ b/vendor/icu_locid/src/langid.rs
@@ -20,7 +20,8 @@ use writeable::Writeable;
///
/// ```
/// use icu::locid::{
-/// langid, subtags_language as language, subtags_region as region,
+/// langid,
+/// subtags::{language, region},
/// };
///
/// let li = langid!("en-US");
@@ -49,8 +50,8 @@ use writeable::Writeable;
///
/// ```
/// use icu::locid::{
-/// langid, subtags_language as language, subtags_region as region,
-/// subtags_script as script, subtags_variant as variant,
+/// langid,
+/// subtags::{language, region, script, variant},
/// };
///
/// let li = langid!("eN_latn_Us-Valencia");
@@ -257,7 +258,7 @@ impl LanguageIdentifier {
/// Compare this `LanguageIdentifier` with a potentially unnormalized BCP-47 string.
///
/// The return value is equivalent to what would happen if you first parsed the
- /// BCP-47 string to a `LanguageIdentifier` and then performed a structucal comparison.
+ /// BCP-47 string to a `LanguageIdentifier` and then performed a structural comparison.
///
/// # Examples
///
@@ -382,9 +383,7 @@ fn test_writeable() {
/// # Examples
///
/// ```
-/// use icu::locid::{
-/// langid, subtags_language as language, LanguageIdentifier,
-/// };
+/// use icu::locid::{langid, subtags::language, LanguageIdentifier};
///
/// assert_eq!(LanguageIdentifier::from(language!("en")), langid!("en"));
/// ```
@@ -400,7 +399,7 @@ impl From<subtags::Language> for LanguageIdentifier {
/// # Examples
///
/// ```
-/// use icu::locid::{langid, subtags_script as script, LanguageIdentifier};
+/// use icu::locid::{langid, subtags::script, LanguageIdentifier};
///
/// assert_eq!(
/// LanguageIdentifier::from(Some(script!("latn"))),
@@ -419,7 +418,7 @@ impl From<Option<subtags::Script>> for LanguageIdentifier {
/// # Examples
///
/// ```
-/// use icu::locid::{langid, subtags_region as region, LanguageIdentifier};
+/// use icu::locid::{langid, subtags::region, LanguageIdentifier};
///
/// assert_eq!(
/// LanguageIdentifier::from(Some(region!("US"))),
@@ -441,8 +440,9 @@ impl From<Option<subtags::Region>> for LanguageIdentifier {
///
/// ```
/// use icu::locid::{
-/// langid, subtags_language as language, subtags_region as region,
-/// subtags_script as script, LanguageIdentifier,
+/// langid,
+/// subtags::{language, region, script},
+/// LanguageIdentifier,
/// };
///
/// let lang = language!("en");
@@ -482,8 +482,8 @@ impl
///
/// ```
/// use icu::locid::{
-/// langid, subtags_language as language, subtags_region as region,
-/// subtags_script as script,
+/// langid,
+/// subtags::{language, region, script},
/// };
///
/// let lid = langid!("en-Latn-US");
diff --git a/vendor/icu_locid/src/lib.rs b/vendor/icu_locid/src/lib.rs
index d9c4f7699..9c6c46ca5 100644
--- a/vendor/icu_locid/src/lib.rs
+++ b/vendor/icu_locid/src/lib.rs
@@ -24,7 +24,8 @@
//! ```
//! use icu::locid::Locale;
//! use icu::locid::{
-//! locale, subtags_language as language, subtags_region as region,
+//! locale,
+//! subtags::{language, region},
//! };
//!
//! let mut loc: Locale = locale!("en-US");
@@ -81,6 +82,7 @@ pub use parser::errors::ParserError;
pub use ParserError as Error;
pub mod extensions;
+#[macro_use]
pub mod subtags;
pub mod zerovec;
diff --git a/vendor/icu_locid/src/locale.rs b/vendor/icu_locid/src/locale.rs
index 4412da86e..e87cdf1a2 100644
--- a/vendor/icu_locid/src/locale.rs
+++ b/vendor/icu_locid/src/locale.rs
@@ -28,8 +28,9 @@ use writeable::Writeable;
///
/// ```
/// use icu_locid::{
-/// extensions_unicode_key as key, extensions_unicode_value as value,
-/// locale, subtags_language as language, subtags_region as region,
+/// extensions::unicode::{key, value},
+/// locale,
+/// subtags::{language, region},
/// };
///
/// let loc = locale!("en-US-u-ca-buddhist");
@@ -56,7 +57,8 @@ use writeable::Writeable;
/// `_` separators to `-` and adjusting casing to conform to the Unicode standard.
///
/// Any bogus subtags will cause the parsing to fail with an error.
-/// No subtag validation or canonicalization is performed.
+///
+/// No subtag validation or alias resolution is performed.
///
/// # Examples
///
@@ -98,13 +100,13 @@ fn test_sizes() {
assert_eq!(core::mem::size_of::<Option<LanguageIdentifier>>(), 32);
assert_eq!(core::mem::size_of::<extensions::transform::Fields>(), 24);
- assert_eq!(core::mem::size_of::<extensions::unicode::Attributes>(), 24);
+ assert_eq!(core::mem::size_of::<extensions::unicode::Attributes>(), 16);
assert_eq!(core::mem::size_of::<extensions::unicode::Keywords>(), 24);
assert_eq!(core::mem::size_of::<Vec<extensions::other::Other>>(), 24);
- assert_eq!(core::mem::size_of::<extensions::private::Private>(), 24);
- assert_eq!(core::mem::size_of::<extensions::Extensions>(), 152);
+ assert_eq!(core::mem::size_of::<extensions::private::Private>(), 16);
+ assert_eq!(core::mem::size_of::<extensions::Extensions>(), 136);
- assert_eq!(core::mem::size_of::<Locale>(), 184);
+ assert_eq!(core::mem::size_of::<Locale>(), 168);
}
impl Locale {
@@ -250,7 +252,7 @@ impl Locale {
/// Compare this `Locale` with a potentially unnormalized BCP-47 string.
///
/// The return value is equivalent to what would happen if you first parsed the
- /// BCP-47 string to a `Locale` and then performed a structucal comparison.
+ /// BCP-47 string to a `Locale` and then performed a structural comparison.
///
/// # Examples
///
@@ -422,7 +424,7 @@ fn test_writeable() {
///
/// ```
/// use icu::locid::Locale;
-/// use icu::locid::{locale, subtags_language as language};
+/// use icu::locid::{locale, subtags::language};
///
/// assert_eq!(Locale::from(language!("en")), locale!("en"));
/// ```
@@ -439,7 +441,7 @@ impl From<subtags::Language> for Locale {
///
/// ```
/// use icu::locid::Locale;
-/// use icu::locid::{locale, subtags_script as script};
+/// use icu::locid::{locale, subtags::script};
///
/// assert_eq!(Locale::from(Some(script!("latn"))), locale!("und-Latn"));
/// ```
@@ -456,7 +458,7 @@ impl From<Option<subtags::Script>> for Locale {
///
/// ```
/// use icu::locid::Locale;
-/// use icu::locid::{locale, subtags_region as region};
+/// use icu::locid::{locale, subtags::region};
///
/// assert_eq!(Locale::from(Some(region!("US"))), locale!("und-US"));
/// ```
@@ -474,8 +476,8 @@ impl From<Option<subtags::Region>> for Locale {
/// ```
/// use icu::locid::Locale;
/// use icu::locid::{
-/// locale, subtags_language as language, subtags_region as region,
-/// subtags_script as script,
+/// locale,
+/// subtags::{language, region, script},
/// };
///
/// assert_eq!(
diff --git a/vendor/icu_locid/src/parser/langid.rs b/vendor/icu_locid/src/parser/langid.rs
index 653ca7e6e..2c6ddeb03 100644
--- a/vendor/icu_locid/src/parser/langid.rs
+++ b/vendor/icu_locid/src/parser/langid.rs
@@ -5,10 +5,10 @@
pub use super::errors::ParserError;
use crate::extensions::unicode::{Attribute, Key, Value};
use crate::extensions::ExtensionType;
+use crate::helpers::ShortSlice;
use crate::parser::SubtagIterator;
use crate::LanguageIdentifier;
use crate::{extensions, subtags};
-use alloc::vec::Vec;
use tinystr::TinyAsciiStr;
#[derive(PartialEq, Clone, Copy)]
@@ -31,7 +31,7 @@ pub fn parse_language_identifier_from_iter(
) -> Result<LanguageIdentifier, ParserError> {
let mut script = None;
let mut region = None;
- let mut variants = Vec::new();
+ let mut variants = ShortSlice::new();
let language = if let Some(subtag) = iter.next() {
subtags::Language::try_from_bytes(subtag)?
@@ -95,7 +95,7 @@ pub fn parse_language_identifier_from_iter(
language,
script,
region,
- variants: subtags::Variants::from_vec_unchecked(variants),
+ variants: subtags::Variants::from_short_slice_unchecked(variants),
})
}
diff --git a/vendor/icu_locid/src/subtags/language.rs b/vendor/icu_locid/src/subtags/language.rs
index 86b51b93a..6fd08a2d5 100644
--- a/vendor/icu_locid/src/subtags/language.rs
+++ b/vendor/icu_locid/src/subtags/language.rs
@@ -5,7 +5,7 @@
impl_tinystr_subtag!(
/// A language subtag (examples: `"en"`, `"csb"`, `"zh"`, `"und"`, etc.)
///
- /// [`Language`] represents a Unicode base language code conformat to the
+ /// [`Language`] represents a Unicode base language code conformant to the
/// [`unicode_language_id`] field of the Language and Locale Identifier.
///
/// # Examples
@@ -34,7 +34,8 @@ impl_tinystr_subtag!(
///
/// [`unicode_language_id`]: https://unicode.org/reports/tr35/#unicode_language_id
Language,
- subtags::Language,
+ subtags,
+ language,
subtags_language,
2..=3,
s,
@@ -63,7 +64,7 @@ impl Language {
/// # Examples
///
/// ```
- /// use icu::locid::{subtags::Language, subtags_language as language};
+ /// use icu::locid::subtags::{language, Language};
///
/// let mut lang = language!("csb");
///
diff --git a/vendor/icu_locid/src/subtags/mod.rs b/vendor/icu_locid/src/subtags/mod.rs
index bd243a321..9cc04dac8 100644
--- a/vendor/icu_locid/src/subtags/mod.rs
+++ b/vendor/icu_locid/src/subtags/mod.rs
@@ -51,8 +51,12 @@ mod script;
mod variant;
mod variants;
-pub use language::Language;
-pub use region::Region;
-pub use script::Script;
-pub use variant::Variant;
+#[doc(inline)]
+pub use language::{language, Language};
+#[doc(inline)]
+pub use region::{region, Region};
+#[doc(inline)]
+pub use script::{script, Script};
+#[doc(inline)]
+pub use variant::{variant, Variant};
pub use variants::Variants;
diff --git a/vendor/icu_locid/src/subtags/region.rs b/vendor/icu_locid/src/subtags/region.rs
index f605937ce..4348f15e7 100644
--- a/vendor/icu_locid/src/subtags/region.rs
+++ b/vendor/icu_locid/src/subtags/region.rs
@@ -5,7 +5,7 @@
impl_tinystr_subtag!(
/// A region subtag (examples: `"US"`, `"CN"`, `"AR"` etc.)
///
- /// [`Region`] represents a Unicode base language code conformat to the
+ /// [`Region`] represents a Unicode base language code conformant to the
/// [`unicode_region_id`] field of the Language and Locale Identifier.
///
/// # Examples
@@ -19,7 +19,8 @@ impl_tinystr_subtag!(
///
/// [`unicode_region_id`]: https://unicode.org/reports/tr35/#unicode_region_id
Region,
- subtags::Region,
+ subtags,
+ region,
subtags_region,
2..=3,
s,
diff --git a/vendor/icu_locid/src/subtags/script.rs b/vendor/icu_locid/src/subtags/script.rs
index 05eb63d1c..79ead0390 100644
--- a/vendor/icu_locid/src/subtags/script.rs
+++ b/vendor/icu_locid/src/subtags/script.rs
@@ -5,7 +5,7 @@
impl_tinystr_subtag!(
/// A script subtag (examples: `"Latn"`, `"Arab"`, etc.)
///
- /// [`Script`] represents a Unicode base language code conformat to the
+ /// [`Script`] represents a Unicode base language code conformant to the
/// [`unicode_script_id`] field of the Language and Locale Identifier.
///
/// # Examples
@@ -19,7 +19,8 @@ impl_tinystr_subtag!(
///
/// [`unicode_script_id`]: https://unicode.org/reports/tr35/#unicode_script_id
Script,
- subtags::Script,
+ subtags,
+ script,
subtags_script,
4..=4,
s,
diff --git a/vendor/icu_locid/src/subtags/variant.rs b/vendor/icu_locid/src/subtags/variant.rs
index 96fd7500e..c60b13865 100644
--- a/vendor/icu_locid/src/subtags/variant.rs
+++ b/vendor/icu_locid/src/subtags/variant.rs
@@ -5,7 +5,7 @@
impl_tinystr_subtag!(
/// A variant subtag (examples: `"macos"`, `"posix"`, `"1996"` etc.)
///
- /// [`Variant`] represents a Unicode base language code conformat to the
+ /// [`Variant`] represents a Unicode base language code conformant to the
/// [`unicode_variant_id`] field of the Language and Locale Identifier.
///
/// # Examples
@@ -19,7 +19,8 @@ impl_tinystr_subtag!(
///
/// [`unicode_variant_id`]: https://unicode.org/reports/tr35/#unicode_variant_id
Variant,
- subtags::Variant,
+ subtags,
+ variant,
subtags_variant,
4..=8,
s,
diff --git a/vendor/icu_locid/src/subtags/variants.rs b/vendor/icu_locid/src/subtags/variants.rs
index 70aeae1d9..ba5ff1bc1 100644
--- a/vendor/icu_locid/src/subtags/variants.rs
+++ b/vendor/icu_locid/src/subtags/variants.rs
@@ -16,7 +16,7 @@ use core::ops::Deref;
/// # Examples
///
/// ```
-/// use icu::locid::{subtags::Variants, subtags_variant as variant};
+/// use icu::locid::subtags::{variant, Variants};
///
/// let mut v = vec![variant!("posix"), variant!("macos")];
/// v.sort();
@@ -48,7 +48,7 @@ impl Variants {
/// # Examples
///
/// ```
- /// use icu::locid::{subtags::Variants, subtags_variant as variant};
+ /// use icu::locid::subtags::{variant, Variants};
///
/// let variants = Variants::from_variant(variant!("posix"));
/// ```
@@ -64,7 +64,7 @@ impl Variants {
/// # Examples
///
/// ```
- /// use icu::locid::{subtags::Variants, subtags_variant as variant};
+ /// use icu::locid::subtags::{variant, Variants};
///
/// let mut v = vec![variant!("posix"), variant!("macos")];
/// v.sort();
@@ -77,7 +77,11 @@ impl Variants {
/// for the caller to use [`binary_search`](slice::binary_search) instead of [`sort`](slice::sort)
/// and [`dedup`](Vec::dedup()).
pub fn from_vec_unchecked(input: Vec<Variant>) -> Self {
- Self(ShortSlice::from(input))
+ Self(input.into())
+ }
+
+ pub(crate) fn from_short_slice_unchecked(input: ShortSlice<Variant>) -> Self {
+ Self(input)
}
/// Empties the [`Variants`] list.
@@ -87,7 +91,7 @@ impl Variants {
/// # Examples
///
/// ```
- /// use icu::locid::{subtags::Variants, subtags_variant as variant};
+ /// use icu::locid::subtags::{variant, Variants};
///
/// let mut v = vec![variant!("posix"), variant!("macos")];
/// v.sort();
@@ -119,6 +123,6 @@ impl Deref for Variants {
type Target = [Variant];
fn deref(&self) -> &[Variant] {
- self.0.as_slice()
+ self.0.deref()
}
}
diff --git a/vendor/icu_locid/src/zerovec.rs b/vendor/icu_locid/src/zerovec.rs
index 530d21499..ba6a3e85d 100644
--- a/vendor/icu_locid/src/zerovec.rs
+++ b/vendor/icu_locid/src/zerovec.rs
@@ -60,8 +60,8 @@
//! use icu_locid::subtags::{Language, Region, Script};
//! use icu_locid::LanguageIdentifier;
//! use icu_locid::{
-//! langid, subtags_language as language, subtags_region as region,
-//! subtags_script as script,
+//! langid,
+//! subtags::{language, region, script},
//! };
//! use zerovec::ZeroMap;
//!