| Crates.io | paft-money |
| lib.rs | paft-money |
| version | 0.7.1 |
| created_at | 2025-10-02 11:39:25.739087+00 |
| updated_at | 2025-10-31 17:56:02.399067+00 |
| description | Currency and money primitives for the paft ecosystem. |
| homepage | https://github.com/paft-rs/paft |
| repository | https://github.com/paft-rs/paft |
| max_upload_size | |
| id | 1864275 |
| size | 217,330 |
Currency and money primitives for the paft ecosystem.
Currency with ISO 4217 integration and extensible fallbackMoney with safe arithmetic and explicit conversions via ExchangeRaterust_decimal, optional bigdecimal feature)XAU, XDR)Prefer the facade crate for most applications:
[dependencies]
paft = "0.7.1"
Advanced (direct dependency, default backend):
[dependencies]
paft-money = "0.7.1"
Alternate decimal backend:
[dependencies]
paft-money = { version = "0.7.1", features = ["bigdecimal"] }
With DataFrame integration or panicking ops:
[dependencies]
paft-money = { version = "0.7.1", features = ["dataframe", "panicking-money-ops"] }
bigdecimal: switch to arbitrary precision decimalsdataframe: Polars integration (ToDataFrame/ToDataFrameVec)panicking-money-ops: opt-in operator overloading that panics on invalid operationsmoney-formatting: locale-aware formatting and strict parsing for Moneyuse iso_currency::Currency as IsoCurrency;
use paft_money::{Currency, Money};
let price = Money::from_canonical_str("12.34", Currency::Iso(IsoCurrency::USD))?;
let tax = Money::from_canonical_str("1.23", Currency::Iso(IsoCurrency::USD))?;
let total = price.try_add(&tax)?;
assert_eq!(total.format(), "13.57 USD");
# Ok::<(), paft_money::MoneyError>(())
When you enable the optional money-formatting feature, localized output lives behind explicit APIs so the canonical Display remains stable ("<amount> <CODE>").
# #[cfg(feature = "money-formatting")]
# {
use iso_currency::Currency as IsoCurrency;
use paft_money::{Currency, Locale, Money};
let eur = Money::from_canonical_str("1234.56", Currency::Iso(IsoCurrency::EUR)).unwrap();
assert_eq!(format!("{eur}"), "1234.56 EUR");
assert_eq!(eur.format_with_locale(Locale::EnEu).unwrap(), "€1.234,56");
assert_eq!(format!("{}", eur.localized(Locale::EnEu).with_code()), "€1.234,56 EUR");
let parsed =
Money::from_str_locale("€1.234,56", Currency::Iso(IsoCurrency::EUR), Locale::EnEu).unwrap();
assert_eq!(parsed.format(), "1234.56 EUR");
# }