pub fn create<L: Into<LanguageIdentifier>>(
        langid: L,
        prt: PluralRuleType,
    ) -> Result<Self, &'static str> {
        let langid = langid.into();
        let returned_rule = match prt {
            PluralRuleType::CARDINAL => {
                let idx = rules::PRS_CARDINAL.binary_search_by_key(&&langid, |(l, _)| l);
                idx.map(|idx| rules::PRS_CARDINAL[idx].1)
            }
            PluralRuleType::ORDINAL => {
                let idx = rules::PRS_ORDINAL.binary_search_by_key(&&langid, |(l, _)| l);
                idx.map(|idx| rules::PRS_ORDINAL[idx].1)
            }
        };
        match returned_rule {
            Ok(returned_rule) => Ok(Self {
                locale: langid,
                function: returned_rule,
            }),
            Err(_) => Err("unknown locale"),
        }
    }
/// Returns an instance of PluralRules.
///
/// # 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);
/// assert_eq!(pr_naq.is_ok(), !pr_naq.is_err());
///
/// let langid: LanguageIdentifier = "xx".parse().expect("Parsing failed.");
/// let pr_broken = PluralRules::create(langid, PluralRuleType::CARDINAL);
/// assert_eq!(pr_broken.is_err(), !pr_broken.is_ok());
/// ```
Returns an instance of PluralRules.
Returns an instance of PluralRules .
pub fn create<L: Into<LanguageIdentifier>>(
        langid: L,
        prt: PluralRuleType,
    ) -> Result<Self, &'static str> {
        let langid = langid.into();
        let returned_rule = match prt {
            PluralRuleType::CARDINAL => {
                let idx = rules::PRS_CARDINAL.binary_search_by_key(&&langid, |(l, _)| l);
                idx.map(|idx| rules::PRS_CARDINAL[idx].1)
            }
            PluralRuleType::ORDINAL => {
                let idx = rules::PRS_ORDINAL.binary_search_by_key(&&langid, |(l, _)| l);
                idx.map(|idx| rules::PRS_ORDINAL[idx].1)
            }
        };
        match returned_rule {
            Ok(returned_rule) => Ok(Self {
                locale: langid,
                function: returned_rule,
            }),
            Err(_) => Err("unknown locale"),
        }
    }
pub fn create < L : Into < LanguageIdentifier > > ( langid : L , prt : PluralRuleType , ) -> Result < Self , & ' static str > { let langid = langid . into ( ) ; let returned_rule = match prt { PluralRuleType :: CARDINAL => { let idx = rules :: PRS_CARDINAL . binary_search_by_key ( & & langid , | ( l , _ ) | l ) ; idx . map ( | idx | rules :: PRS_CARDINAL [ idx ] . 1 ) } PluralRuleType :: ORDINAL => { let idx = rules :: PRS_ORDINAL . binary_search_by_key ( & & langid , | ( l , _ ) | l ) ; idx . map ( | idx | rules :: PRS_ORDINAL [ idx ] . 1 ) } } ; match returned_rule { Ok ( returned_rule ) => Ok ( Self { locale : langid , function : returned_rule , } ) , Err ( _ ) => Err ( " " ) , } }
Returns an instance of PluralRules.
Returns an instance of PluralRules .
langid
L
prt
PluralRuleType
langid
L
prt
PluralRuleType
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);
assert_eq!(pr_naq.is_ok(), !pr_naq.is_err()).

let langid: LanguageIdentifier = "xx".parse().expect("Parsing failed.");
let pr_broken = PluralRules::create(langid, PluralRuleType::CARDINAL);
assert_eq!(pr_broken.is_err(), !pr_broken.is_ok());
```
` ` ` 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 ) ; assert_eq! ( pr_naq . is_ok () !pr_naq . is_err () ) . let langid : LanguageIdentifier = " xx " . parse () . expect ( " Parsing failed . " ) ; let pr_broken = PluralRules :: create ( langid PluralRuleType :: CARDINAL ) ; assert_eq! ( pr_broken . is_err () !pr_broken . is_ok () ) ; ` ` `