rust_decimal_ext/
lib.rs

1#![doc = include_str!(concat!(env!("OUT_DIR"), "/README-lib.md"))]
2#![forbid(unsafe_code)]
3#![deny(clippy::print_stdout, clippy::print_stderr)]
4#![cfg_attr(not(feature = "std"), no_std)]
5#![cfg_attr(docsrs, feature(doc_auto_cfg))]
6extern crate alloc;
7
8mod constants;
9mod decimal;
10mod error;
11mod ops;
12mod str;
13
14// We purposely place this here for documentation ordering
15mod arithmetic_impls;
16
17mod arithmetic_ext;
18
19#[cfg(feature = "rust-fuzz")]
20mod fuzz;
21#[cfg(feature = "maths")]
22mod maths;
23#[cfg(feature = "db-diesel-mysql")]
24mod mysql;
25#[cfg(any(
26    feature = "db-tokio-postgres",
27    feature = "db-postgres",
28    feature = "db-diesel-postgres",
29))]
30mod postgres;
31#[cfg(feature = "proptest")]
32mod proptest;
33#[cfg(feature = "rand")]
34mod rand;
35#[cfg(feature = "rocket-traits")]
36mod rocket;
37#[cfg(all(
38    feature = "serde",
39    not(any(
40        feature = "serde-with-str",
41        feature = "serde-with-float",
42        feature = "serde-with-arbitrary-precision"
43    ))
44))]
45mod serde;
46/// Serde specific functionality to customize how a decimal is serialized/deserialized (`serde_with`)
47#[cfg(all(
48    feature = "serde",
49    any(
50        feature = "serde-with-str",
51        feature = "serde-with-float",
52        feature = "serde-with-arbitrary-precision"
53    )
54))]
55pub mod serde;
56
57pub use decimal::{Decimal, RoundingStrategy};
58pub use error::Error;
59#[cfg(feature = "maths")]
60pub use maths::MathematicalOps;
61
62// #[cfg(feature = "macros")]
63// pub use rust_decimal_macros::dec;
64
65/// A convenience module appropriate for glob imports (`use rust_decimal::prelude::*;`).
66pub mod prelude {
67    #[cfg(feature = "maths")]
68    pub use crate::maths::MathematicalOps;
69    pub use crate::{Decimal, RoundingStrategy};
70    pub use core::str::FromStr;
71    pub use num_traits::{FromPrimitive, One, Signed, ToPrimitive, Zero};
72    // #[cfg(feature = "macros")]
73    // pub use rust_decimal_macros::dec;
74}
75
76#[cfg(feature = "diesel")]
77extern crate diesel;
78
79/// Shortcut for `core::result::Result<T, rust_decimal::Error>`. Useful to distinguish
80/// between `rust_decimal` and `std` types.
81pub type Result<T> = core::result::Result<T, Error>;
82
83// #[cfg(feature = "legacy-ops")]
84// compiler_error!("legacy-ops has been removed as 1.x");