Expand description
§Positive
A type-safe wrapper for guaranteed positive decimal values.
This crate provides the Positive type, which encapsulates a Decimal value and ensures
through its API that the contained value is always positive (greater than or equal to zero).
§Features
- Type Safety: Compile-time guarantees that values are non-negative
- Decimal Precision: Built on
rust_decimalfor accurate financial calculations - Rich API: Comprehensive arithmetic operations, conversions, and utilities
- Serde Support: Full serialization/deserialization support
§Example
use positive::{Positive, pos};
let price = pos!(100.50);
let quantity = Positive::new(10.0).unwrap();
let total = price * quantity;Re-exports§
pub use error::PositiveError;pub use error::PositiveResult;
Modules§
- error
- Error types for the Positive decimal type.
Macros§
- pos
- Macro for creating a new
Positivevalue with simplified syntax. - spos
- A macro to create an optional
Positivevalue from the given expression.
Structs§
- Decimal
- Re-export rust_decimal for convenience.
Decimalrepresents a 128 bit representation of a fixed-precision decimal number. The finite set of values of typeDecimalare of the form m / 10e, where m is an integer such that -296 < m < 296, and e is an integer between 0 and 28 inclusive. - Positive
- A wrapper type that represents a guaranteed positive decimal value.
Constants§
- EPSILON
- Default epsilon value for approximate comparisons.
Functions§
- is_
positive - Determines if the given type parameter
Tis thePositivetype.