# Brief description
"Down-to-earth" (explained further below) money [^fowler] and currency implementation written in Rust.
See further below for more detailed design considerations.
as described by Martin Fowler in his [Money EAA Pattern](https://martinfowler.com/eaaCatalog/money.html).
# Usage
```rust
// You create a Currency either with a string code ...
let eur = Currency::new("EUR", 2)?;
// ... or a byte array ...
let kwt = Currency::new_using_bytes(b"KWD", 2)?;
// ... you need a byte array also to create a constant (compiler doesn't allow unwrap) ...
const EUR: Currency = Currency::new_using_bytes_const(b"EUR", 2);
// ... and use either to instantiate Money instances:
let money1 = Money { full_amount_as_minor: 12_95, currency: eur };
let money2 = Money { full_amount_as_minor: 15_99, currency: EUR };
let result = money1 + money2;
```
# Other implementations
Simple Money has similar implementations in other programming languages.
There's a [_Simple Money_ project page on BitBucket](https://bitbucket.org/afischl/workspace/projects/MONEY), but I haven't published all of them.
# Features and design considerations
Features in common with all implementations: see [Design Considerations](DESIGN.md)
# Comparison to similar libraries
Here are two alternatives I've found:
- [steel-cent](https://crates.io/crates/steel-cent)
- uses an i64 for the amount, just like this implementation
- has the same precision as the minor amount allows (no "half Cents")
- its currency has the `Copy` trait and is as small as mine
- the ISO currencies are provided, but IntelliJ's Rust plugin fails to see them (works in the terminal though)
- [rusty-money](https://crates.io/crates/rusty-money):
- uses its own 128 representation for the amount
- has more precision than available by the minor amount
- its currency...
- has lots of fields, ...
- ... but the ISO currencies are provided ready to use
- has the `Copy` trait, but is eighty bytes in size
- is bristling with features (e.g. exchange rates?)