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