rust_decimal_ext 1.36.0

Decimal number implementation written in pure Rust suitable for financial and fixed-precision calculations.
Documentation

rust_decimal_ext   Latest Version Docs Badge

rust_decimal_ext is an extension library that adds more operator trait support to rust_decimal. With this library, you can more conveniently perform arithmetic operations on Decimal types, supporting automatic conversion and addition with numbers, strings, and other types.

Usage

use rust_decimal_ext::prelude::*;

let mut a = Decimal::from(100) + 100;
let mut b = Decimal::from(100) + 3.14;
let mut c = Decimal::from(100) + "3.14";
let mut d = Decimal::from(100) + "3.14".to_string();

a += 100;
b += 3.14;
c += "3.14";
d += "3.14";

assert!(a == 300);
assert!(b == 106.28);
assert!(c == "106.28");
assert!(d == "106.28");