[−][src]Crate rusty_money
Handle money and currency conversions.
Money lets you handle currencies in Rust easily and takes care of rounding, currency tracking and parsing monetary symbols according to ISO standards.
Use
The easiest way to create Money is by using the flexible money! macro:
ⓘThis code runs with edition 2018
money = money!("-200.00", "USD"); money = money!(-200, "USD");
Money handles rounding for you based on the properties of the currency:
ⓘThis code runs with edition 2018
money = money!("-200.009", "USD"); println!("{:?}", money) // -200.01 USD TODO - show a currency with different exponent
You can perform basic operations on money like:
ⓘThis code runs with edition 2018
hundred = money!("100", "USD"); thousand = money!("1000", "USD") println!("{:?}", hundred + thousand) // 1000 USD println!("{:?}", thousand > hundred) // false println!("{:?}", thousand.is_positive()) // true
Currency is still a work in progress, but has hardcoded values for USD and GBP.
Macros
money |
Structs
Currency | |
Money |