varunsrin / rusty_money

Money library for Rust
MIT License
93 stars 34 forks source link

`Money::from_str` cannot parse numbers greater than `i32::MAX` #83

Closed jiftoo closed 1 year ago

jiftoo commented 1 year ago

Money::from_str only allows values that fit in a 32 bit integer to be parsed, while other methods allow for at least 64 bit integers.

assert_eq!(
    Money::from_major(i64::MAX, iso::EUR)
        .amount()
        .to_i64()
        .unwrap(),
    i64::MAX
);
assert!(Money::from_str(&i32::MAX.to_string(), iso::EUR).is_ok());
assert!(Money::from_str(&(i32::MAX as i64 + 1).to_string(), iso::EUR).is_err()); // the problem