[−][src]Struct intl_pluralrules::IntlPluralRules
The main structure for selecting plural rules.
Examples
use intl_pluralrules::{IntlPluralRules, PluralRuleType, PluralCategory}; use unic_langid::LanguageIdentifier; let langid: LanguageIdentifier = "naq".parse().expect("Parsing failed."); let pr_naq = IntlPluralRules::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));
Methods
impl IntlPluralRules[src]
pub fn create<L: Into<LanguageIdentifier>>(
langid: L,
prt: PluralRuleType
) -> Result<Self, &'static str>[src]
langid: L,
prt: PluralRuleType
) -> Result<Self, &'static str>
Returns an instance of IntlPluralRules.
Examples
use intl_pluralrules::{IntlPluralRules, PluralRuleType, PluralCategory}; use unic_langid::LanguageIdentifier; let langid: LanguageIdentifier = "naq".parse().expect("Parsing failed."); let pr_naq = IntlPluralRules::create(langid, PluralRuleType::CARDINAL); assert_eq!(pr_naq.is_ok(), !pr_naq.is_err()); let langid: LanguageIdentifier = "xx".parse().expect("Parsing failed."); let pr_broken = IntlPluralRules::create(langid, PluralRuleType::CARDINAL); assert_eq!(pr_broken.is_err(), !pr_broken.is_ok());
pub fn select<N: IntoPluralOperands>(
&self,
number: N
) -> Result<PluralCategory, &'static str>[src]
&self,
number: N
) -> Result<PluralCategory, &'static str>
Returns a result of the plural category for the given input.
If the input is not numeric.
Examples
use intl_pluralrules::{IntlPluralRules, PluralRuleType, PluralCategory}; use unic_langid::LanguageIdentifier; let langid: LanguageIdentifier = "naq".parse().expect("Parsing failed."); let pr_naq = IntlPluralRules::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), Ok(PluralCategory::OTHER));
pub fn get_locales(prt: PluralRuleType) -> Vec<LanguageIdentifier>[src]
Returns a list of the available locales.
Examples
use intl_pluralrules::{IntlPluralRules, PluralRuleType}; assert_eq!( IntlPluralRules::get_locales(PluralRuleType::CARDINAL).is_empty(), false );
pub fn get_locale(&self) -> &LanguageIdentifier[src]
Returns the locale name for this PluralRule instance.
Examples
use intl_pluralrules::{IntlPluralRules, PluralRuleType}; use unic_langid::LanguageIdentifier; let langid: LanguageIdentifier = "naq".parse().expect("Parsing failed."); let pr_naq = IntlPluralRules::create(langid.clone(), PluralRuleType::CARDINAL).unwrap(); assert_eq!(pr_naq.get_locale(), &langid);
Trait Implementations
impl Clone for IntlPluralRules[src]
fn clone(&self) -> IntlPluralRules[src]
fn clone_from(&mut self, source: &Self)1.0.0[src]
Performs copy-assignment from source. Read more
Auto Trait Implementations
impl Unpin for IntlPluralRules
impl Sync for IntlPluralRules
impl Send for IntlPluralRules
impl UnwindSafe for IntlPluralRules
impl RefUnwindSafe for IntlPluralRules
Blanket Implementations
impl<T> ToOwned for T where
T: Clone, [src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
fn to_owned(&self) -> T[src]
fn clone_into(&self, target: &mut T)[src]
impl<T> From<T> for T[src]
impl<T, U> Into<U> for T where
U: From<T>, [src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>, [src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>, [src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>[src]
impl<T> Borrow<T> for T where
T: ?Sized, [src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized, [src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T[src]
impl<T> Any for T where
T: 'static + ?Sized, [src]
T: 'static + ?Sized,