[−][src]Trait intl_pluralrules::operands::IntoPluralOperands
A trait that can be implemented on any type to allow it for passing to select
. This trait is made public for implementations of custom types. If you are using generic types, you should use from
.
Example
use intl_pluralrules::operands::*; use intl_pluralrules::{IntlPluralRules, PluralRuleType, PluralCategory}; use unic_langid::LanguageIdentifier; struct MyType { value: isize } impl IntoPluralOperands for MyType { fn into_plural(self) -> Result<PluralOperands, &'static str> { Ok(PluralOperands { n: self.value as f64, i: self.value as isize, v: 0, w: 0, f: 0, t: 0, }) } } let langid: LanguageIdentifier = "en".parse().expect("Parsing failed."); let pr = IntlPluralRules::create(langid, PluralRuleType::CARDINAL).unwrap(); let v = MyType { value: 5 }; assert_eq!(pr.select(v), Ok(PluralCategory::OTHER));