//! Example showing how to localize fixed_decimal decimals
usefixed_decimal::Decimal;useicu_locale::locale;usel10n_embed::{Context, Localize};fnmain()->Result<(), fixed_decimal::LimitError>{// Create some decimals
let zero:i32=0;let five_million:u64=5_000_000;let zero_point_two:f64=0.2;letmut negative_two_point_five =Decimal::from(-25);
negative_two_point_five.multiply_pow10(-1);let context =Context::new(locale!("en-US"),true);letmut buffer =String::new();// Localize those decimals into a human-readable number
let numbers:[(&str,Box<dyn Localize>);4]=[("Zero",Box::new(zero)),("Five million",Box::new(five_million)),("Zero point two",Box::new(zero_point_two)),("Negative two point five",Box::new(negative_two_point_five)),];for(name, number)in numbers {
buffer.clear();
number.localize(&context,&mut buffer);println!("{name}: {buffer}");}Ok(())}