Skip to content

Commit

Permalink
Merge branch 'main' into of
Browse files Browse the repository at this point in the history
  • Loading branch information
robertbastian committed Feb 14, 2025
2 parents 549b0b7 + 0b8985f commit d131203
Show file tree
Hide file tree
Showing 273 changed files with 4,426 additions and 4,195 deletions.
4 changes: 2 additions & 2 deletions CODEOWNERS
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ components/collator/ @hsivonen @echeran
components/collections/ @echeran
components/datetime/ @sffc @zbraniecki
components/decimal/ @sffc
components/experimental/src/compactdecimal/ @eggrobin
components/experimental/src/compactdecimal/ @younies
components/experimental/src/dimension/ @younies
components/experimental/src/displaynames/ @sffc @snktd
components/experimental/src/relativetime/ @pdogr
Expand All @@ -24,7 +24,7 @@ components/locale_core/ @zbraniecki @nciric
components/normalizer/ @hsivonen @echeran
components/plurals/ @zbraniecki @sffc
components/segmenter/ @aethanyc @makotokato @sffc
components/timezone/ @nekevss @robertbastian @sffc
components/time/ @nekevss @robertbastian @sffc
tutorials/gn/ @sffc
ffi/capi/ @Manishearth
ffi/ecma402/ @filmil
Expand Down
13 changes: 6 additions & 7 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ members = [
"components/plurals",
"components/properties",
"components/segmenter",
"components/timezone",
"components/time",

# FFI
"ffi/capi",
Expand Down Expand Up @@ -59,7 +59,7 @@ members = [
"provider/data/plurals",
"provider/data/properties",
"provider/data/segmenter",
"provider/data/timezone",
"provider/data/time",

# Utils
"utils/bies",
Expand Down Expand Up @@ -151,7 +151,7 @@ icu_normalizer = { version = "~2.0.0-beta1", path = "components/normalizer", def
icu_plurals = { version = "~2.0.0-beta1", path = "components/plurals", default-features = false }
icu_properties = { version = "~2.0.0-beta1", path = "components/properties", default-features = false }
icu_segmenter = { version = "~2.0.0-beta1", path = "components/segmenter", default-features = false }
icu_timezone = { version = "~2.0.0-beta1", path = "components/timezone", default-features = false }
icu_time = { version = "~2.0.0-beta1", path = "components/time", default-features = false }

# FFI
icu_capi = { version = "~2.0.0-beta1", path = "ffi/capi", default-features = false }
Expand Down Expand Up @@ -181,7 +181,7 @@ icu_normalizer_data = { version = "~2.0.0-beta1", path = "provider/data/normaliz
icu_plurals_data = { version = "~2.0.0-beta1", path = "provider/data/plurals", default-features = false }
icu_properties_data = { version = "~2.0.0-beta1", path = "provider/data/properties", default-features = false }
icu_segmenter_data = { version = "~2.0.0-beta1", path = "provider/data/segmenter", default-features = false }
icu_timezone_data = { version = "~2.0.0-beta1", path = "provider/data/timezone", default-features = false }
icu_time_data = { version = "~2.0.0-beta1", path = "provider/data/time", default-features = false }
icu_experimental_data = { version = "~0.2.0-dev", path = "provider/data/experimental", default-features = false }

# Utils
Expand Down
4 changes: 1 addition & 3 deletions components/calendar/src/any_calendar.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,9 @@ use crate::persian::Persian;
use crate::roc::Roc;
use crate::{types, AsCalendar, Calendar, Date, DateDuration, DateDurationUnit, Ref};

use crate::preferences::{CalendarAlgorithm, IslamicCalendarAlgorithm};
use icu_locale_core::extensions::unicode::{key, value, Value};
use icu_locale_core::preferences::define_preferences;
use icu_locale_core::preferences::extensions::unicode::keywords::{
CalendarAlgorithm, IslamicCalendarAlgorithm,
};
use icu_locale_core::subtags::language;
use icu_locale_core::Locale;
use icu_provider::prelude::*;
Expand Down
12 changes: 12 additions & 0 deletions components/calendar/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -190,3 +190,15 @@ pub use error::{DateError, RangeError};
pub use gregorian::Gregorian;
#[doc(no_inline)]
pub use iso::Iso;

/// Locale preferences used by this crate
pub mod preferences {
#[doc(inline)]
/// **This is a reexport of a type in [`icu::locale`](icu_locale_core::preferences::extensions::unicode::keywords)**.
#[doc = "\n"] // prevent autoformatting
pub use icu_locale_core::preferences::extensions::unicode::keywords::CalendarAlgorithm;
#[doc(inline)]
/// **This is a reexport of a type in [`icu::locale`](icu_locale_core::preferences::extensions::unicode::keywords)**.
#[doc = "\n"] // prevent autoformatting
pub use icu_locale_core::preferences::extensions::unicode::keywords::IslamicCalendarAlgorithm;
}
12 changes: 7 additions & 5 deletions components/collator/README.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions components/collator/fuzz/fuzz_targets/compare_utf16.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
use core::cmp::Ordering;
use core::convert::TryFrom;
use icu_collator::AlternateHandling;
use icu_collator::CaseFirst;
use icu_collator::CollationCaseFirst;
use icu_collator::Collator;
use icu_collator::CollatorOptions;
use icu_collator::MaxVariable;
Expand Down Expand Up @@ -102,9 +102,9 @@ fn compare_icu4c(
.unwrap();

let case_first = match options.case_first() {
CaseFirst::UpperFirst => UColAttributeValue::UCOL_UPPER_FIRST,
CaseFirst::LowerFirst => UColAttributeValue::UCOL_LOWER_FIRST,
CaseFirst::Off => UColAttributeValue::UCOL_OFF,
CollationCaseFirst::UpperFirst => UColAttributeValue::UCOL_UPPER_FIRST,
CollationCaseFirst::LowerFirst => UColAttributeValue::UCOL_LOWER_FIRST,
CollationCaseFirst::Off => UColAttributeValue::UCOL_OFF,
};
collator
.set_attribute(UColAttribute::UCOL_CASE_FIRST, case_first)
Expand Down
15 changes: 8 additions & 7 deletions components/collator/src/comparison.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ use crate::provider::CollationSpecialPrimaries;
use crate::provider::CollationSpecialPrimariesV1;
use crate::provider::CollationTailoringV1;
use crate::{
AlternateHandling, CaseFirst, CollationType, CollatorOptions, MaxVariable, NumericOrdering,
preferences::CollationCaseFirst, preferences::CollationNumericOrdering,
preferences::CollationType, AlternateHandling, CollatorOptions, MaxVariable,
ResolvedCollatorOptions, Strength,
};
use core::cmp::Ordering;
Expand Down Expand Up @@ -83,27 +84,27 @@ icu_locale_core::preferences::define_preferences!(
/// ## Case First
///
/// See the [spec](https://www.unicode.org/reports/tr35/tr35-collation.html#Case_Parameters).
/// This is the BCP47 key `kf`. Three possibilities: [`CaseFirst::False`] (default,
/// except for Danish and Maltese), [`CaseFirst::Lower`], and [`CaseFirst::Upper`]
/// This is the BCP47 key `kf`. Three possibilities: [`CollationCaseFirst::False`] (default,
/// except for Danish and Maltese), [`CollationCaseFirst::Lower`], and [`CollationCaseFirst::Upper`]
/// (default for Danish and Maltese).
///
/// ## Numeric
///
/// This is the BCP47 key `kn`. When set to [`NumericOrdering::True`], any sequence of decimal
/// This is the BCP47 key `kn`. When set to [`CollationNumericOrdering::True`], any sequence of decimal
/// digits (General_Category = Nd) is sorted at the primary level according to the
/// numeric value. The default is [`NumericOrdering::False`].
/// numeric value. The default is [`CollationNumericOrdering::False`].
[Copy]
CollatorPreferences,
{
/// The collation type. This corresponds to the `-u-co` BCP-47 tag.
collation_type: CollationType,
/// Treatment of case. (Large and small kana differences are treated as case differences.)
/// This corresponds to the `-u-kf` BCP-47 tag.
case_first: CaseFirst,
case_first: CollationCaseFirst,
/// When set to `True`, any sequence of decimal digits is sorted at a primary level according
/// to the numeric value.
/// This corresponds to the `-u-kn` BPC-47 tag.
numeric_ordering: NumericOrdering
numeric_ordering: CollationNumericOrdering
}
);

Expand Down
28 changes: 20 additions & 8 deletions components/collator/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -251,27 +251,28 @@
//! ```
//! use core::cmp::Ordering;
//! use icu::collator::*;
//! use icu::collator::preferences::*;
//!
//! // Use the locale's default.
//!
//! let mut prefs_no_case = CollatorPreferences::default();
//! prefs_no_case.case_first = Some(CaseFirst::False);
//! prefs_no_case.case_first = Some(CollationCaseFirst::False);
//! let collator_no_case =
//! Collator::try_new(prefs_no_case, Default::default()).unwrap();
//! assert_eq!(collator_no_case.compare("ab", "AB"), Ordering::Less);
//!
//! // Lowercase is less
//!
//! let mut prefs_lower_less = CollatorPreferences::default();
//! prefs_lower_less.case_first = Some(CaseFirst::Lower);
//! prefs_lower_less.case_first = Some(CollationCaseFirst::Lower);
//! let collator_lower_less =
//! Collator::try_new(prefs_lower_less, Default::default()).unwrap();
//! assert_eq!(collator_lower_less.compare("ab", "AB"), Ordering::Less);
//!
//! // Uppercase is less
//!
//! let mut prefs_upper_greater = CollatorPreferences::default();
//! prefs_upper_greater.case_first = Some(CaseFirst::Upper);
//! prefs_upper_greater.case_first = Some(CollationCaseFirst::Upper);
//! let collator_upper_greater =
//! Collator::try_new(prefs_upper_greater, Default::default()).unwrap();
//! assert_eq!(collator_upper_greater.compare("AB", "ab"), Ordering::Less);
Expand All @@ -286,19 +287,20 @@
//! ```
//! use core::cmp::Ordering;
//! use icu::collator::*;
//! use icu::collator::preferences::*;
//!
//! // Numerical sorting off
//!
//! let mut prefs_num_off = CollatorPreferences::default();
//! prefs_num_off.numeric_ordering = Some(NumericOrdering::False);
//! prefs_num_off.numeric_ordering = Some(CollationNumericOrdering::False);
//! let collator_num_off =
//! Collator::try_new(prefs_num_off, Default::default()).unwrap();
//! assert_eq!(collator_num_off.compare("a10b", "a2b"), Ordering::Less);
//!
//! // Numerical sorting on
//!
//! let mut prefs_num_on = CollatorPreferences::default();
//! prefs_num_on.numeric_ordering = Some(NumericOrdering::True);
//! prefs_num_on.numeric_ordering = Some(CollationNumericOrdering::True);
//! let collator_num_on =
//! Collator::try_new(prefs_num_on, Default::default()).unwrap();
//! assert_eq!(collator_num_on.compare("a10b", "a2b"), Ordering::Greater);
Expand All @@ -320,13 +322,23 @@ pub mod provider;
pub use comparison::Collator;
pub use comparison::CollatorBorrowed;
pub use comparison::CollatorPreferences;
pub use icu_locale_core::preferences::extensions::unicode::keywords::CollationCaseFirst as CaseFirst;
pub use icu_locale_core::preferences::extensions::unicode::keywords::CollationNumericOrdering as NumericOrdering;
pub use icu_locale_core::preferences::extensions::unicode::keywords::CollationType;
pub use options::AlternateHandling;
pub use options::BackwardSecondLevel;
pub use options::CaseLevel;
pub use options::CollatorOptions;
pub use options::MaxVariable;
pub use options::ResolvedCollatorOptions;
pub use options::Strength;

/// Locale preferences used by this crate
pub mod preferences {
/// **This is a reexport of a type in [`icu::locale`](icu_locale_core::preferences::extensions::unicode::keywords)**.
#[doc = "\n"] // prevent autoformatting
pub use icu_locale_core::preferences::extensions::unicode::keywords::CollationCaseFirst;
/// **This is a reexport of a type in [`icu::locale`](icu_locale_core::preferences::extensions::unicode::keywords)**.
#[doc = "\n"] // prevent autoformatting
pub use icu_locale_core::preferences::extensions::unicode::keywords::CollationNumericOrdering;
/// **This is a reexport of a type in [`icu::locale`](icu_locale_core::preferences::extensions::unicode::keywords)**.
#[doc = "\n"] // prevent autoformatting
pub use icu_locale_core::preferences::extensions::unicode::keywords::CollationType;
}
Loading

0 comments on commit d131203

Please sign in to comment.