zbraniecki / pluralrules

Pluralization handling in Rust
36 stars 4 forks source link

Example in the documentation could use more comments #16

Closed kornelski closed 6 years ago

kornelski commented 6 years ago

https://docs.rs/intl_pluralrules/0.9.0/intl_pluralrules/#examples

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

let permanent: &'static str = "naq";
let locale_code = &permanent;

assert!(IntlPluralRules::get_locales(PluralRuleType::CARDINAL).contains(&permanent));

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

assert_eq!(pr_naq.get_locale(), "naq");

What is "naq"?

Why is locale code &&str?

I guess contains(&permanent) was meant to be contains(locale_code)?

It'd be great to have examples of "cardinal" and "ordinal", since these are specific terms that may not be known by non-native English speakers.

zbraniecki commented 6 years ago

Yep, that's an error. Thanks for noticing! @unclenachoduh