pub fn serialize(rule: &Rule, w: &mut impl Write) -> Result
Expand description
Unicode Plural Rule serializer converts an AST
to a String
.
🚧 This code is considered unstable; it may change at any time, in breaking or non-breaking ways,
including in SemVer minor releases. In particular, the `DataProvider` implementations are only
guaranteed to match with this version's `*_unstable` providers. Use with caution.
§Examples
use icu::plurals::provider::rules::reference::ast;
use icu::plurals::provider::rules::reference::parse;
use icu::plurals::provider::rules::reference::serialize;
let input = "i = 0 or n = 1 @integer 0, 1 @decimal 0.0~1.0, 0.00~0.04";
let ast = parse(input.as_bytes()).expect("Parsing failed.");
assert_eq!(ast.condition.0[0].0[0].expression.operand, ast::Operand::I);
assert_eq!(ast.condition.0[1].0[0].expression.operand, ast::Operand::N);
let mut result = String::new();
serialize(&ast, &mut result).expect("Serialization failed.");
assert_eq!(input, result);