Add documentation for Decimal::to_u<xx>(&self) methods
All the methods that takes a reference to a Decimal object and returns an integer type, round the Decimal down to nearest integer, without any explicit mentioning of this. The current documentation for the Decimal::to_u64(&self) -> Option
rust_decimal::decimal::Decimal
fn to_u64(&self) -> Option<u64>
---
Converts the value of self to a u64. If the value cannot be
represented by a u64, then None is returned.
Would it make sense for me to (at least) add to the method documentations that the calls are dropping the fractional part? Or is this kind of thing implied when using the crate?
It matches the behaviour of the standard library in similar situations, but it's easy enough to do so I see no reason not to.
It matches the behaviour of the standard library in similar situations, but it's easy enough to do so I see no reason not to.
Yeah I just test with:
fn main() {
let float: f64 = 0.5;
let integer = float as u32;
println!("{}", integer);
}
$ 0
I believe that the documentation should be added only if there is a clear consensus that the current version is misleading