varunsrin / rusty_money

Money library for Rust
MIT License
85 stars 32 forks source link

`Display` impl writes "-$0.00" when precision is higher than two decimal places #79

Open parasyte opened 1 year ago

parasyte commented 1 year ago
use rusty_money::{iso, Money};

fn main() {
    let money = Money::from_str("-0.005", iso::USD).unwrap();
    assert_eq!(format!("{money}"), "$0.00");
}

Fails with:

thread 'main' panicked at 'assertion failed: `(left == right)`
  left: `"-$0.00"`,
 right: `"$0.00"`', src\main.rs:5:5

The Display impl should never print "negative zero dollars".