use-money 0.1.0

Money primitives pairing amounts and currencies for RustUse finance crates
Documentation
  • Coverage
  • 100%
    15 out of 15 items documented1 out of 12 items with examples
  • Size
  • Source code size: 9.15 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 474.01 kB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 2s Average build duration of successful builds.
  • all releases: 2s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • Homepage
  • RustUse/use-finance
    3 0 0
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • CloudBranch

use-money

Money primitives pairing amounts and currencies for RustUse finance crates.

use-money combines a scaled integer Amount with a validated CurrencyCode and provides checked arithmetic only when currencies match.

Example

use use_amount::Amount;
use use_currency::CurrencyCode;
use use_money::Money;

let usd = CurrencyCode::new("USD")?;
let left = Money::new(Amount::from_minor_units(10_000, 2)?, usd.clone());
let right = Money::new(Amount::from_minor_units(2_500, 2)?, usd);

assert_eq!(left.checked_sub(&right)?.amount().minor_units(), 7_500);
# Ok::<(), Box<dyn std::error::Error>>(())

Scope

Use this crate for currency-safe money values and checked same-currency addition/subtraction. It does not provide exchange rates, rounding policy engines, tax calculations, live financial data, or formatting by locale.

License

Licensed under either MIT or Apache-2.0.