zbraniecki / pluralrules

Pluralization handling in Rust
36 stars 4 forks source link

Support providing numbers with selected precision #34

Open zbraniecki opened 4 years ago

zbraniecki commented 4 years ago

Thanks, I can confirm that my previous test no longer panics when using the updated pluralrules.

The thing that struck me as potentially difficult about starting with a float is that when the decimal places haven't been rigidly set by the caller, you'd need to determine how many decimal places are appropriate, and it seems like you'd end up reimplementing the logic in format that does so

assert_eq!(&format!("{}", 3.020000000000000007), "3.02");

The logic looks to be non-trivial:

https://github.com/rust-lang/rust/blob/master/src/libcore/num/flt2dec/mod.rs

Originally posted by @dae in https://github.com/projectfluent/fluent-rs/pull/162#issuecomment-603557722