Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
347 changes: 304 additions & 43 deletions Cargo.lock

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ members = [
"utils/ixdtf",
"utils/litemap",
"utils/resb",
"utils/env_preferences",
"utils/host_info",
"utils/tinystr",
"utils/tzif",
"utils/potential_utf",
Expand Down
23 changes: 23 additions & 0 deletions components/locale_core/src/extensions/unicode/attributes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,29 @@ impl Attributes {
{
self.deref().iter().map(|t| t.as_str()).try_for_each(f)
}

/// Extends the `Attributes` with values from another `Attributes`.
///
/// # Example
///
/// ```
/// use icu::locale::extensions::unicode::Attributes;
///
/// let mut attrs: Attributes = "foobar-foobaz".parse().unwrap();
/// let attrs2: Attributes = "foobar-fooqux".parse().unwrap();
///
/// attrs.extend(attrs2);
///
/// assert_eq!(attrs, "foobar-foobaz-fooqux".parse().unwrap());
/// ```
#[cfg(feature = "alloc")]
pub fn extend(&mut self, other: Attributes) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

issue: these are new public APIs, we should consider these carefully

cc @sffc @robertbastian

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is reviewed in #7112

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, thanks!

for attr in other.0 {
if let Err(idx) = self.binary_search(&attr) {
self.0.insert(idx, attr);
}
}
}
}

/// ✨ *Enabled with the `alloc` Cargo feature.*
Expand Down
21 changes: 21 additions & 0 deletions components/locale_core/src/extensions/unicode/keywords.rs
Original file line number Diff line number Diff line change
Expand Up @@ -386,6 +386,27 @@ impl Keywords {
Ok(())
}

/// Extends the `Keywords` with values from another `Keywords`.
///
/// # Example
///
/// ```
/// use icu::locale::extensions::unicode::Keywords;
///
/// let mut kw: Keywords = "ab-cd-ca-buddhist".parse().unwrap();
/// let kw2: Keywords = "ca-gregory-hc-h12".parse().unwrap();
///
/// kw.extend(kw2);
///
/// assert_eq!(kw, "ab-cd-ca-gregory-hc-h12".parse().unwrap());
/// ```
#[cfg(feature = "alloc")]
pub fn extend(&mut self, other: Keywords) {
for (key, value) in other.0 {
self.0.insert(key, value);
}
}

/// This needs to be its own method to help with type inference in helpers.rs
#[cfg(test)]
pub(crate) fn from_tuple_vec(v: Vec<(Key, Value)>) -> Self {
Expand Down
20 changes: 20 additions & 0 deletions components/locale_core/src/extensions/unicode/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,26 @@ impl Unicode {
}
Ok(())
}

/// Extends the `Unicode` with values from another `Unicode`.
///
/// # Example
///
/// ```
/// use icu::locale::extensions::unicode::Unicode;
///
/// let mut ue: Unicode = "u-foobar-ca-buddhist".parse().unwrap();
/// let ue2: Unicode = "u-ca-gregory-hc-h12".parse().unwrap();
///
/// ue.extend(ue2);
///
/// assert_eq!(ue, "u-foobar-ca-gregory-hc-h12".parse().unwrap());
/// ```
#[cfg(feature = "alloc")]
pub fn extend(&mut self, other: Unicode) {
self.keywords.extend(other.keywords);
self.attributes.extend(other.attributes);
}
}

/// ✨ *Enabled with the `alloc` Cargo feature.*
Expand Down
2 changes: 1 addition & 1 deletion components/locale_core/src/preferences/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
//!
//! # Preferences Merging
//!
//! In traditional internatonalization APIs, the argument passed to constructors is a locale.
//! In traditional internationalization APIs, the argument passed to constructors is a locale.
//! ICU4X changes this paradigm by accepting a `Preferences`, which can be extracted from a [`Locale`] and combined with
//! other `Preferences`s provided by the environment.
//!
Expand Down
14 changes: 0 additions & 14 deletions utils/env_preferences/README.md

This file was deleted.

170 changes: 0 additions & 170 deletions utils/env_preferences/src/apple.rs

This file was deleted.

98 changes: 0 additions & 98 deletions utils/env_preferences/src/error.rs

This file was deleted.

Loading
Loading