1#![doc = include_str!("../README.md")]
2#![forbid(unsafe_code)]
3#![forbid(clippy::float_arithmetic)]
4#![forbid(clippy::float_cmp)]
5#![forbid(clippy::as_conversions)]
6#![forbid(clippy::cast_possible_truncation)]
7#![forbid(clippy::cast_sign_loss)]
8#![forbid(clippy::cast_possible_wrap)]
9#![forbid(clippy::unwrap_used)]
10
11pub mod prelude {
13 pub use crate::BaseMoney;
14 pub use crate::BaseOps;
15 pub use crate::Currency;
16 pub use crate::IterOps;
17 pub use crate::MoneyFormatter;
18 pub use crate::MoneyOps;
19 pub use crate::PercentOps;
20 pub use crate::RoundingStrategy;
21 pub use crate::{Decimal, Money, MoneyError};
22
23 pub use crate::iso;
24
25 pub use crate::macros::{dec, money};
26
27 #[cfg(feature = "raw_money")]
28 pub use crate::RawMoney;
29 #[cfg(feature = "raw_money")]
30 pub use crate::macros::raw;
31
32 #[cfg(feature = "exchange")]
33 pub use crate::exchange::{Exchange, ExchangeRates};
34
35 #[cfg(feature = "obj_money")]
36 pub use crate::ObjMoney;
37
38 #[cfg(feature = "accounting")]
39 pub use crate::AccountingOps;
40
41 #[cfg(feature = "accounting")]
42 pub use crate::accounting;
43
44 #[cfg(feature = "serde")]
45 pub use crate::serde;
46}
47
48#[cfg(not(any(feature = "exchange", feature = "accounting")))]
51pub trait MoneyOps<C>: BaseOps<C> + MoneyFormatter<C> + PercentOps<C>
53where
54 C: Currency,
55{
56}
57
58#[cfg(all(feature = "exchange", not(feature = "accounting")))]
59pub trait MoneyOps<C>: BaseOps<C> + MoneyFormatter<C> + PercentOps<C> + Exchange<C>
61where
62 C: Currency,
63{
64}
65
66#[cfg(feature = "accounting")]
67pub trait AccountingOps<C>: accounting::interest::InterestOps<C> {}
69
70#[cfg(all(feature = "accounting", not(feature = "exchange")))]
71pub trait MoneyOps<C>: BaseOps<C> + MoneyFormatter<C> + PercentOps<C> + AccountingOps<C>
73where
74 C: Currency,
75{
76}
77
78#[cfg(all(feature = "exchange", feature = "accounting"))]
79pub trait MoneyOps<C>:
81 BaseOps<C> + MoneyFormatter<C> + PercentOps<C> + Exchange<C> + AccountingOps<C>
82where
83 C: Currency,
84{
85}
86
87pub use rust_decimal::Decimal;
90
91pub mod macros;
93
94mod base;
95pub use base::{BaseMoney, BaseOps, IterOps, MoneyFormatter, RoundingStrategy};
96
97mod error;
98pub use error::MoneyError;
99
100pub use currencylib::Currency;
101
102pub mod iso {
104 pub use currencylib::*;
105}
106
107mod money;
108pub use money::Money;
109
110#[cfg(feature = "raw_money")]
111mod raw_money;
112#[cfg(feature = "raw_money")]
113pub use raw_money::RawMoney;
114
115mod dec_ops;
116mod iter_ops;
117mod ops;
118mod percent_ops;
119pub use percent_ops::PercentOps;
120mod split_alloc_ops;
121
122#[cfg(feature = "exchange")]
123mod exchange;
124#[cfg(feature = "exchange")]
125pub use exchange::{Exchange, ExchangeRates};
126
127#[cfg(feature = "accounting")]
128pub mod accounting;
130
131#[cfg(feature = "accounting")]
132mod calendar;
133
134#[cfg(feature = "serde")]
135pub mod serde;
137
138mod fmt;
139
140mod parse;
141
142#[cfg(feature = "obj_money")]
143mod obj_money;
144#[cfg(feature = "obj_money")]
145pub use obj_money::ObjMoney;
146
147#[cfg(test)]
150mod parse_test;
151
152#[cfg(test)]
153mod fmt_test;
154
155#[cfg(test)]
156mod money_test;
157
158#[cfg(test)]
159mod error_test;
160
161#[cfg(test)]
162mod ops_test;
163
164#[cfg(test)]
165mod iter_ops_test;
166
167#[cfg(test)]
168mod percent_ops_test;
169
170#[cfg(test)]
171mod split_alloc_ops_test;
172
173#[cfg(all(test, feature = "exchange"))]
174mod exchange_test;
175
176#[cfg(all(test, feature = "accounting"))]
177mod calendar_test;