Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement AsULE for PluralCategory #4496

Merged
merged 3 commits into from
Dec 27, 2023
Merged
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
14 changes: 8 additions & 6 deletions components/plurals/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,8 @@ pub enum PluralRuleType {
#[derive(Debug, PartialEq, Eq, Clone, Copy, Hash, Ord, PartialOrd)]
#[cfg_attr(feature = "datagen", derive(serde::Serialize))]
#[cfg_attr(feature = "serde", derive(serde::Deserialize))]
#[repr(u8)]
#[zerovec::make_ule(PluralCategoryULE)]
#[allow(clippy::exhaustive_enums)] // this type is mostly stable. new categories may potentially be added in the future,
// but at a cadence slower than the ICU4X release cycle
pub enum PluralCategory {
Expand All @@ -160,7 +162,7 @@ pub enum PluralCategory {
///
/// - 0 in Arabic (ar), Latvian (lv)
/// - 10~20, 30, 40, 50, ... in Latvian (lv)
Zero,
Zero = 0,
/// CLDR "one" plural category. Signifies the singular form in many languages.
///
/// Examples of numbers having this category:
Expand All @@ -169,14 +171,14 @@ pub enum PluralCategory {
/// - 1 in English (en) and most other languages
/// - 2.1 in Filipino (fil), Croatian (hr), Latvian (lv), Serbian (sr)
/// - 2, 3, 5, 7, 8, ... in Filipino (fil)
One,
One = 1,
/// CLDR "two" plural category. Used in Arabic, Hebrew, and Slovenian, among others.
///
/// Examples of numbers having this category:
///
/// - 2 in Arabic (ar), Hebrew (iw), Slovenian (sl)
/// - 2.0 in Arabic (ar)
Two,
Two = 2,
/// CLDR "few" plural category. Used in Romanian, Polish, Russian, and others.
///
/// Examples of numbers having this category:
Expand All @@ -185,7 +187,7 @@ pub enum PluralCategory {
/// - 1.2 in Croatian (hr), Romanian (ro), Slovenian (sl), Serbian (sr)
/// - 2 in Polish (pl), Russian (ru), Czech (cs), ...
/// - 5 in Arabic (ar), Lithuanian (lt), Romanian (ro)
Few,
Few = 3,
/// CLDR "many" plural category. Used in Polish, Russian, Ukrainian, and others.
///
/// Examples of numbers having this category:
Expand All @@ -194,7 +196,7 @@ pub enum PluralCategory {
/// - 1.0 in Czech (cs), Slovak (sk)
/// - 1.1 in Czech (cs), Lithuanian (lt), Slovak (sk)
/// - 15 in Arabic (ar), Polish (pl), Russian (ru), Ukrainian (uk)
Many,
Many = 4,
/// CLDR "other" plural category, used as a catch-all. Each language supports it, and it
/// is also used as a fail safe result for in case no better match can be identified.
///
Expand All @@ -206,7 +208,7 @@ pub enum PluralCategory {
/// - 0 in English (en), German (de), Spanish (es), ...
/// - 1 in Japanese (ja), Korean (ko), Chinese (zh), Thai (th), ...
/// - 2 in English (en), German (de), Spanish (es), ...
Other,
Other = 5,
}

impl PluralCategory {
Expand Down
3 changes: 3 additions & 0 deletions tools/ffi_coverage/src/allowlist.rs
Original file line number Diff line number Diff line change
Expand Up @@ -399,6 +399,9 @@ lazy_static::lazy_static! {
"icu::timezone::Error",
"icu::transliterator::Error",

// ULE types that are not in provider modules
"icu::plurals::PluralCategoryULE",

// "Internal" trait that should never be called directly
"icu::calendar::Calendar",
// Rust-specific calendar wrapper stuff
Expand Down