lucre 0.7.0

An ergonomic library for handling money.
Documentation
# lucre

[![status-badge](https://ci.cosmicrose.dev/api/badges/43/status.svg)](https://ci.cosmicrose.dev/repos/43)
[![Crates.io Version](https://img.shields.io/crates/v/lucre)](https://crates.io/crates/lucre)
[![docs.rs](https://img.shields.io/docsrs/lucre)](https://docs.rs/lucre)

An ergonomic Rust library for handling money.

Represent money in your applications without fussing over generics or
lifetimes, while still being safe and fast. [ISO 4217] currency definitions are
built in.

[ISO 4217]: https://en.wikipedia.org/wiki/ISO_4217

## Install

Add `lucre` to your `Cargo.toml`.

```toml
[dependencies]
lucre = "0.7.0"
```

## Usage

The `Money` struct is the primary interface, with the `Currency` struct supporting it.
`Currency` contains constants for all current ISO 4217 currencies.

```rust
use lucre::{Money, Currency, Format, MoneyError};

fn main() -> Result<(), MoneyError> {
    // Create money from major or minor units
    let subtotal = Money::from_major(100, &Currency::USD);
    let tax = Money::from_minor(475, &Currency::USD);

    // Arithmetic is available as either checked or panicking operations
    let _unchecked = subtotal + tax;
    let total = subtotal.checked_add(&tax)?;

    // The display format has sensible defaults...
    assert_eq!(total.to_string(), "104.75 USD");

    // ...which can be overridden
    let format = Format::default().symbol();
    assert_eq!(total.format_with(&format).to_string(), "$104.75");

    Ok(())
}
```

## Maintainer

This project is maintained by [Rosa Richter](https://cosmicrose.dev).
For ways to contact her, see her [contact page](https://cosmicrose.dev/contact/).

## Contributing

Questions and contributions are absolutely welcome!
Please [create an issue](https://code.cosmicrose.dev/rosa/lucre/issues/new)
for bugs, feature requests, or questions.

## License

[BSD-2-Clause-Patent](https://spdx.org/licenses/BSD-2-Clause-Patent.html) © Rosa Richter