pub struct Decimal { /* private fields */ }Expand description
An exact checked base-10 decimal backed by an i128 coefficient.
Implementations§
Source§impl Decimal
impl Decimal
pub const ZERO: Self
pub fn new(coefficient: i128, scale: u8) -> Result<Self, DecimalError>
pub const fn coefficient(self) -> i128
pub const fn scale(self) -> u8
pub const fn is_zero(self) -> bool
pub const fn is_positive(self) -> bool
pub const fn is_negative(self) -> bool
pub fn checked_add(self, rhs: Self) -> Result<Self, DecimalError>
pub fn checked_sub(self, rhs: Self) -> Result<Self, DecimalError>
pub fn checked_mul(self, rhs: Self) -> Result<Self, DecimalError>
pub fn checked_from_f64(value: f64) -> Result<Self, DecimalError>
pub fn checked_rescale(self, scale: u8) -> Result<Self, DecimalError>
Trait Implementations§
impl Copy for Decimal
Source§impl<'de> Deserialize<'de> for Decimal
impl<'de> Deserialize<'de> for Decimal
Source§fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>where
D: Deserializer<'de>,
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>where
D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
impl Eq for Decimal
Source§impl From<NonNegativeDecimal> for Decimal
impl From<NonNegativeDecimal> for Decimal
Source§fn from(value: NonNegativeDecimal) -> Self
fn from(value: NonNegativeDecimal) -> Self
Converts to this type from the input type.
Source§impl From<PositiveDecimal> for Decimal
impl From<PositiveDecimal> for Decimal
Source§fn from(value: PositiveDecimal) -> Self
fn from(value: PositiveDecimal) -> Self
Converts to this type from the input type.
Source§impl Ord for Decimal
impl Ord for Decimal
1.21.0 (const: unstable) · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Compares and returns the maximum of two values. Read more
1.21.0 (const: unstable) · Source§fn min(self, other: Self) -> Selfwhere
Self: Sized,
fn min(self, other: Self) -> Selfwhere
Self: Sized,
Compares and returns the minimum of two values. Read more
Source§impl PartialOrd for Decimal
impl PartialOrd for Decimal
impl StructuralPartialEq for Decimal
Source§impl TryFrom<Decimal> for PositiveDecimal
impl TryFrom<Decimal> for PositiveDecimal
Source§impl TryFrom<Decimal> for NonNegativeDecimal
impl TryFrom<Decimal> for NonNegativeDecimal
Auto Trait Implementations§
impl Freeze for Decimal
impl RefUnwindSafe for Decimal
impl Send for Decimal
impl Sync for Decimal
impl Unpin for Decimal
impl UnsafeUnpin for Decimal
impl UnwindSafe for Decimal
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more