1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
//! # A library for handling currencies
//!
//! When working with currencies, decimals only need to be precise up to the smallest cent value while avoiding
//! common floating point errors when performing basic arithmetic. currency_rs resolves this issue by working with
//! `vodo` behind the scenes, so you don't have to be concerned about decimal precision.
//!
//! ## Quick startup
//!
//! ```
//! use currency_rs::{Currency, CurrencyOpts};
//!
//! fn main() {
//!     let item_price = 1.33;
//!     let qty = 3.;
//!     let flat_discount = 10.;
//!     let cur_opts = Some(
//!         CurrencyOpts::new()
//!             .set_pattern("$ #")
//!             .set_precision(2)
//!             .set_increment(0.001),
//!     );
//!     let mut cur = Currency::new_float(item_price, cur_opts);
//!     cur = cur.multiply(qty);
//!
//!     if cur.value() > 30. {
//!         cur = cur.subtract(flat_discount);
//!     }
//!
//!     let final_total = cur.format();
//!
//!     println!("Final Total: {}", final_total);
//! }
//! ```

mod currency;
mod currency_opts;

pub use currency::Currency;
pub use currency_opts::CurrencyOpts;

#[cfg(test)]
mod currency_test;