[−][src]Function icu::plurals::rules::parse
pub fn parse(input: &[u8]) -> Result<Rule, ParserError>
Unicode Plural Rule parser converts an
input string into a Rule AST
.
A single Rule
contains a Condition
and optionally a set of
Samples
.
A Condition
can be then used by the resolver
to test
against PluralOperands
, to find the appropriate PluralCategory
.
Samples
are useful for tooling to help translators understand examples of numbers
covered by the given Rule
.
At runtime, only the Condition
is used and for that, consider using parse_condition
.
Examples
use icu_plurals::rules::parse; let input = b"i = 0 or n = 1 @integer 0, 1 @decimal 0.0~1.0, 0.00~0.04"; assert_eq!(parse(input).is_ok(), true);