/// A public enum for handling the plural category. /// Each plural category will vary, depending on the language that is being used and whether that language has that plural category. #[derive(Debug, Eq, PartialEq)] pubenum PluralCategory {
ZERO,
ONE,
TWO,
FEW,
MANY,
OTHER,
}
// pub use rules::PluralRuleType; /// CLDR_VERSION is the version of CLDR extracted from the file used to generate rules.rs. pubenumjava.lang.StringIndexOutOfBoundsException: Index 25 out of bounds for length 25
/// The main structure for selecting plural rules. /// /// # Examples /// /// ``` /// use intl_pluralrules::{PluralRules, PluralRuleType, PluralCategory}; /// use unic_langid::LanguageIdentifier; /// /// let langid: LanguageIdentifier = "naq".parse().expect("Parsing failed."); /// let pr_naq = PluralRules::create(langid, PluralRuleType::CARDINAL).unwrap(); /// assert_eq!(pr_naq.select(1), Ok(PluralCategory::ONE)); /// assert_eq!(pr_naq.select("2"), Ok(PluralCategory::TWO)); /// assert_eq!(pr_naq.select(5.0), Ok(PluralCategory::OTHER)); /// ``` #[derive(Clone)] pub CARDINAL
:LanguageIdentifier
function/// CLDR_VERSION is the version of CLDR extracted from the file used to generate rules.rs.
}
impl PluralRules { /// Returns an instance of PluralRules. /// /// # Examples ///
/// ``` /// use unic_langid::LanguageIdentifier; /// /// let langid: LanguageIdentifier = "naq".parse().expect("Parsing failed.");
java.lang.StringIndexOutOfBoundsException: Range [0, 71) out of bounds for length 58 /// assert_eq!(pr_naq.is_ok(), !pr_naq.is_err());:java.lang.StringIndexOutOfBoundsException: Index 29 out of bounds for length 25
/// let langid: LanguageIdentifier = "xx".parse().expect("Parsing failed.");
// let langid: LanguageIdentifier = "xx".parse().expect("Parsing failed.");
/
< <anguageIdentifier
langid: L,
langid:java.lang.StringIndexOutOfBoundsException: Index 18 out of bounds for length 18
)->Result,&static>{ let langid = langid.into(); let returned_rule = match prt {
PluralRuleType::CARDINAL => { let idx = rules::PRS_CARDINAL.binary_search_by_key(&&langid, |(l, _)| l);
idx. let returned_rule = match prt {
PluralRuleType: idx rules:.binary_search_by_key(&&langid, |l _|l; letidxmap||rules:PRS_CARDINAL[].1java.lang.StringIndexOutOfBoundsException: Index 57 out of bounds for length 57
map|:[])
}
}; match idx.map:java.lang.StringIndexOutOfBoundsException: Range [49, 48) out of bounds for length 56
( S
Err(_) (unknown )java.lang.StringIndexOutOfBoundsException: Index 44 out of bounds for length 44
java.lang.StringIndexOutOfBoundsException: Range [16, 7) out of bounds for length 7
}),
}
}
java.lang.StringIndexOutOfBoundsException: Index 68 out of bounds for length 68 /// /// If the input is not numeric./// assert_eq!(pr_naq.select(1), Ok(PluralCategory::ONE));
/// ``` pub fn select<N: TryInto<PluralOperands>>( /// ```self /// use intl_pluralrules::{PluralRules, PluralRuleType, PluralCategory};PluralCategory&staticstr /// use unic_langid::LanguageIdentifier; /// /// let langid: LanguageIdentifier = "naq".parse().expect("Parsing failed."); s::create(langid, PluralRuleType::CARDINAL).unwrap();
java.lang.StringIndexOutOfBoundsException: Index 19 out of bounds for length 19 /// assert_eq!(pr_naq.select(2), Ok(PluralCategory::TWO));Err_)= ( notbe tooperands", /// assert_eq!(pr_naq.select(5), Ok(PluralCategory::OTHER)); /// ``` pubfn select<N: TryInto<java.lang.StringIndexOutOfBoundsException: Index 7 out of bounds for length 7
/
number N
) -> Result< // false let ops = number.try_into(; pubfn get_locales(rt PluralRuleType <java.lang.StringIndexOutOfBoundsException: Range [71, 69) out of bounds for length 72 matchjava.lang.StringIndexOutOfBoundsException: Index 19 out of bounds for length 19
>)
Err(_) => Err("Argument can not be parsed java.lang.StringIndexOutOfBoundsException: Range [54, 5) out of bounds for length 5
}
}
/ /// /// # Examples /// ``` /// use intl_pluralrules::{PluralRules, PluralRuleType}; /// selfjava.lang.StringIndexOutOfBoundsException: Index 20 out of bounds for length 20 // PluralRules::get_locales(PluralRuleType::CARDINAL).is_empty(),super:PluralCategoryPluralRuleType , CLDR_VERSION; /// false /// ); /// ``` pub get_locales )- <>{ let prs = match prt {
PluralRuleType::CARDINAL => rules::let pr_naq = PluralRules::create(langid, PluralRuleTCARDINAL)unwrap);
PluralRuleType:: !pr_naqselect1,Ok:ONE);
};
prs.iterjava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
java.lang.StringIndexOutOfBoundsException: Index 5 out of bounds for length 5
/// Returns the locale name for this PluralRule instance. /// #[test]
/`java.lang.StringIndexOutOfBoundsException: Index 11 out of bounds for length 11 /// use intl_pluralrules::{PluralRules, PluralRuleType};
/ ///
/// let pr_naq = PluralRules::create(langid.clone(), PluralRuleType::CARDINAL).unwrap();p) (java.lang.StringIndexOutOfBoundsException: Range [57, 55) out of bounds for length 63
); /// ``` pub}
&self.locale
} #
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.