Struct intl_pluralrules::IntlPluralRules[][src]

pub struct IntlPluralRules { /* fields omitted */ }

The main structure for selecting plural rules.

Examples

extern crate intl_pluralrules;
use intl_pluralrules::{IntlPluralRules, PluralRuleType, PluralCategory};

let pr_naq = IntlPluralRules::create("naq", 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]

Returns an instance of IntlPluralRules.

Examples

extern crate intl_pluralrules;
use intl_pluralrules::{IntlPluralRules, PluralRuleType};

let pr_naq = IntlPluralRules::create("naq", PluralRuleType::CARDINAL);
assert_eq!(pr_naq.is_ok(), !pr_naq.is_err());

let pr_broken = IntlPluralRules::create("test", PluralRuleType::CARDINAL);
assert_eq!(pr_broken.is_err(), !pr_broken.is_ok());

Returns a result of the plural category for the given input.

If the input is not numeric.

Examples

extern crate intl_pluralrules;
use intl_pluralrules::{IntlPluralRules, PluralRuleType, PluralCategory};

let pr_naq = IntlPluralRules::create("naq", 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));

Returns a list of the available locales.

Examples

extern crate intl_pluralrules;
use intl_pluralrules::{IntlPluralRules, PluralRuleType};

let pr_naq = IntlPluralRules::create("naq", PluralRuleType::CARDINAL);
assert_eq!(
    IntlPluralRules::get_locales(PluralRuleType::CARDINAL).is_empty(),
    false
);

Returns the locale name for this PluralRule instance.

Examples

extern crate intl_pluralrules;
use intl_pluralrules::{IntlPluralRules, PluralRuleType};

let pr_naq = IntlPluralRules::create("naq", PluralRuleType::CARDINAL).unwrap();
assert_eq!(pr_naq.get_locale(), "naq");

Trait Implementations

impl Debug for IntlPluralRules
[src]

Formats the value using the given formatter. Read more

impl Clone for IntlPluralRules
[src]

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

impl PartialEq for IntlPluralRules
[src]

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.

Auto Trait Implementations