#[repr(transparent)]pub struct Decimal<I, const D: u8>(pub I);Tuple Fields§
§0: IImplementations§
Source§impl<I, const D: u8> Decimal<I, D>where
I: ScaledInteger<D>,
impl<I, const D: u8> Decimal<I, D>where
I: ScaledInteger<D>,
Source§impl<I, const D: u8> Decimal<I, D>where
I: ScaledInteger<D>,
impl<I, const D: u8> Decimal<I, D>where
I: ScaledInteger<D>,
pub const ZERO: Decimal<I, D>
pub const ONE: Decimal<I, D>
pub const TWO: Decimal<I, D>
pub const DECIMALS: u8 = D
pub const SCALING_FACTOR: I = I::SCALING_FACTOR
pub fn min() -> Self
pub fn max() -> Self
Sourcepub fn try_from_scaled(integer: I, scale: u8) -> Option<Self>
pub fn try_from_scaled(integer: I, scale: u8) -> Option<Self>
Losslessly converts a scaled integer to this type.
§Examples
use const_decimal::Decimal;
let five = Decimal::<u64, 3>::try_from_scaled(5, 0).unwrap();
assert_eq!(five, Decimal::TWO + Decimal::TWO + Decimal::ONE);
assert_eq!(five.0, 5000);pub fn is_zero(&self) -> bool
Trait Implementations§
Source§impl<I, const D: u8> AddAssign for Decimal<I, D>where
I: ScaledInteger<D>,
impl<I, const D: u8> AddAssign for Decimal<I, D>where
I: ScaledInteger<D>,
Source§fn add_assign(&mut self, rhs: Self)
fn add_assign(&mut self, rhs: Self)
Performs the
+= operation. Read moreSource§impl<I, const D: u8> DivAssign for Decimal<I, D>where
I: ScaledInteger<D>,
impl<I, const D: u8> DivAssign for Decimal<I, D>where
I: ScaledInteger<D>,
Source§fn div_assign(&mut self, rhs: Self)
fn div_assign(&mut self, rhs: Self)
Performs the
/= operation. Read moreSource§impl<I, const D: u8> MulAssign for Decimal<I, D>where
I: ScaledInteger<D>,
impl<I, const D: u8> MulAssign for Decimal<I, D>where
I: ScaledInteger<D>,
Source§fn mul_assign(&mut self, rhs: Self)
fn mul_assign(&mut self, rhs: Self)
Performs the
*= operation. Read moreSource§impl<I: Ord, const D: u8> Ord for Decimal<I, D>
impl<I: Ord, const D: u8> Ord for Decimal<I, D>
1.21.0 · 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
Source§impl<I: PartialOrd, const D: u8> PartialOrd for Decimal<I, D>
impl<I: PartialOrd, const D: u8> PartialOrd for Decimal<I, D>
Source§impl<I, const D: u8> SubAssign for Decimal<I, D>where
I: ScaledInteger<D>,
impl<I, const D: u8> SubAssign for Decimal<I, D>where
I: ScaledInteger<D>,
Source§fn sub_assign(&mut self, rhs: Self)
fn sub_assign(&mut self, rhs: Self)
Performs the
-= operation. Read moreimpl<I: Copy, const D: u8> Copy for Decimal<I, D>
impl<I: Eq, const D: u8> Eq for Decimal<I, D>
impl<I, const D: u8> StructuralPartialEq for Decimal<I, D>
Auto Trait Implementations§
impl<I, const D: u8> Freeze for Decimal<I, D>where
I: Freeze,
impl<I, const D: u8> RefUnwindSafe for Decimal<I, D>where
I: RefUnwindSafe,
impl<I, const D: u8> Send for Decimal<I, D>where
I: Send,
impl<I, const D: u8> Sync for Decimal<I, D>where
I: Sync,
impl<I, const D: u8> Unpin for Decimal<I, D>where
I: Unpin,
impl<I, const D: u8> UnwindSafe for Decimal<I, D>where
I: UnwindSafe,
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