pub struct Decimal { /* private fields */ }Implementations§
Source§impl Decimal
impl Decimal
pub const MAX_SCALE: u8 = MAX_DIGITS
pub fn from_parts(unscaled: i256, scale: u8) -> Option<Self>
pub fn parse(text: &str) -> Result<Self, ParseError>
pub fn zero() -> Self
pub fn one() -> Self
pub fn from_i64(value: i64) -> Self
pub fn from_i128(value: i128) -> Self
pub fn from_u128(value: u128) -> Self
pub fn from_f64(value: f64) -> Option<Self>
pub fn from_f32(value: f32) -> Option<Self>
pub fn saturated(negative: bool, scale: u8) -> Self
pub fn unscaled(&self) -> i256
pub fn scale(&self) -> u8
pub fn digits(&self) -> u8
pub fn is_zero(&self) -> bool
pub fn is_negative(&self) -> bool
pub fn negate(&self) -> Self
pub fn abs(&self) -> Self
pub fn trunc(&self) -> i256
pub fn ceil(&self) -> i256
pub fn floor(&self) -> i256
pub fn to_f64(&self) -> f64
pub fn to_f32(&self) -> f32
pub fn rescale(&self, scale: u8) -> Option<Self>
pub fn round_to_scale(&self, scale: u8) -> Option<Self>
pub fn fits(&self, precision: u8, scale: u8) -> Option<Self>
pub fn checked_add(&self, other: &Self) -> Option<Self>
pub fn checked_sub(&self, other: &Self) -> Option<Self>
pub fn checked_mul(&self, other: &Self) -> Option<Self>
pub fn checked_pow(&self, exp: u32) -> Option<Self>
pub fn checked_div(&self, other: &Self) -> Option<Self>
pub fn checked_rem(&self, other: &Self) -> Option<Self>
pub fn saturating_add(&self, other: &Self) -> Self
pub fn saturating_sub(&self, other: &Self) -> Self
pub fn saturating_mul(&self, other: &Self) -> Self
pub fn saturating_div(&self, other: &Self) -> Self
pub fn saturating_rem(&self, other: &Self) -> Self
Trait Implementations§
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 FromColumnView for Decimal
impl FromColumnView for Decimal
fn from_column_view( view: &ColumnView<'_>, index: usize, ) -> StdResult<Option<Self>, ColumnReadReason>
impl IsFloat for Decimal
impl IsNumber for Decimal
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
Source§impl Promote<Decimal> for Decimal
impl Promote<Decimal> for Decimal
type Output = Decimal
fn checked_promote(&self, r: &Decimal) -> Option<(Self::Output, Self::Output)>
fn saturating_promote(&self, r: &Decimal) -> (Self::Output, Self::Output)
fn wrapping_promote(&self, r: &Decimal) -> (Self::Output, Self::Output)
fn compare(&self, r: &R) -> Option<Ordering>
Source§impl Promote<Decimal> for f32
impl Promote<Decimal> for f32
type Output = Decimal
fn checked_promote(&self, r: &Decimal) -> Option<(Self::Output, Self::Output)>
fn saturating_promote(&self, r: &Decimal) -> (Self::Output, Self::Output)
fn wrapping_promote(&self, r: &Decimal) -> (Self::Output, Self::Output)
fn compare(&self, r: &R) -> Option<Ordering>
Source§impl Promote<Decimal> for f64
impl Promote<Decimal> for f64
type Output = Decimal
fn checked_promote(&self, r: &Decimal) -> Option<(Self::Output, Self::Output)>
fn saturating_promote(&self, r: &Decimal) -> (Self::Output, Self::Output)
fn wrapping_promote(&self, r: &Decimal) -> (Self::Output, Self::Output)
fn compare(&self, r: &R) -> Option<Ordering>
Source§impl Promote<Decimal> for i8
impl Promote<Decimal> for i8
type Output = Decimal
fn checked_promote(&self, r: &Decimal) -> Option<(Self::Output, Self::Output)>
fn saturating_promote(&self, r: &Decimal) -> (Self::Output, Self::Output)
fn wrapping_promote(&self, r: &Decimal) -> (Self::Output, Self::Output)
fn compare(&self, r: &R) -> Option<Ordering>
Source§impl Promote<Decimal> for i16
impl Promote<Decimal> for i16
type Output = Decimal
fn checked_promote(&self, r: &Decimal) -> Option<(Self::Output, Self::Output)>
fn saturating_promote(&self, r: &Decimal) -> (Self::Output, Self::Output)
fn wrapping_promote(&self, r: &Decimal) -> (Self::Output, Self::Output)
fn compare(&self, r: &R) -> Option<Ordering>
Source§impl Promote<Decimal> for i32
impl Promote<Decimal> for i32
type Output = Decimal
fn checked_promote(&self, r: &Decimal) -> Option<(Self::Output, Self::Output)>
fn saturating_promote(&self, r: &Decimal) -> (Self::Output, Self::Output)
fn wrapping_promote(&self, r: &Decimal) -> (Self::Output, Self::Output)
fn compare(&self, r: &R) -> Option<Ordering>
Source§impl Promote<Decimal> for i64
impl Promote<Decimal> for i64
type Output = Decimal
fn checked_promote(&self, r: &Decimal) -> Option<(Self::Output, Self::Output)>
fn saturating_promote(&self, r: &Decimal) -> (Self::Output, Self::Output)
fn wrapping_promote(&self, r: &Decimal) -> (Self::Output, Self::Output)
fn compare(&self, r: &R) -> Option<Ordering>
Source§impl Promote<Decimal> for i128
impl Promote<Decimal> for i128
type Output = Decimal
fn checked_promote(&self, r: &Decimal) -> Option<(Self::Output, Self::Output)>
fn saturating_promote(&self, r: &Decimal) -> (Self::Output, Self::Output)
fn wrapping_promote(&self, r: &Decimal) -> (Self::Output, Self::Output)
fn compare(&self, r: &R) -> Option<Ordering>
Source§impl Promote<Decimal> for u8
impl Promote<Decimal> for u8
type Output = Decimal
fn checked_promote(&self, r: &Decimal) -> Option<(Self::Output, Self::Output)>
fn saturating_promote(&self, r: &Decimal) -> (Self::Output, Self::Output)
fn wrapping_promote(&self, r: &Decimal) -> (Self::Output, Self::Output)
fn compare(&self, r: &R) -> Option<Ordering>
Source§impl Promote<Decimal> for u16
impl Promote<Decimal> for u16
type Output = Decimal
fn checked_promote(&self, r: &Decimal) -> Option<(Self::Output, Self::Output)>
fn saturating_promote(&self, r: &Decimal) -> (Self::Output, Self::Output)
fn wrapping_promote(&self, r: &Decimal) -> (Self::Output, Self::Output)
fn compare(&self, r: &R) -> Option<Ordering>
Source§impl Promote<Decimal> for u32
impl Promote<Decimal> for u32
type Output = Decimal
fn checked_promote(&self, r: &Decimal) -> Option<(Self::Output, Self::Output)>
fn saturating_promote(&self, r: &Decimal) -> (Self::Output, Self::Output)
fn wrapping_promote(&self, r: &Decimal) -> (Self::Output, Self::Output)
fn compare(&self, r: &R) -> Option<Ordering>
Source§impl Promote<Decimal> for u64
impl Promote<Decimal> for u64
type Output = Decimal
fn checked_promote(&self, r: &Decimal) -> Option<(Self::Output, Self::Output)>
fn saturating_promote(&self, r: &Decimal) -> (Self::Output, Self::Output)
fn wrapping_promote(&self, r: &Decimal) -> (Self::Output, Self::Output)
fn compare(&self, r: &R) -> Option<Ordering>
Source§impl Promote<Decimal> for u128
impl Promote<Decimal> for u128
type Output = Decimal
fn checked_promote(&self, r: &Decimal) -> Option<(Self::Output, Self::Output)>
fn saturating_promote(&self, r: &Decimal) -> (Self::Output, Self::Output)
fn wrapping_promote(&self, r: &Decimal) -> (Self::Output, Self::Output)
fn compare(&self, r: &R) -> Option<Ordering>
Source§impl Promote<f32> for Decimal
impl Promote<f32> for Decimal
type Output = Decimal
fn checked_promote(&self, r: &f32) -> Option<(Self::Output, Self::Output)>
fn saturating_promote(&self, r: &f32) -> (Self::Output, Self::Output)
fn wrapping_promote(&self, r: &f32) -> (Self::Output, Self::Output)
fn compare(&self, r: &R) -> Option<Ordering>
Source§impl Promote<f64> for Decimal
impl Promote<f64> for Decimal
type Output = Decimal
fn checked_promote(&self, r: &f64) -> Option<(Self::Output, Self::Output)>
fn saturating_promote(&self, r: &f64) -> (Self::Output, Self::Output)
fn wrapping_promote(&self, r: &f64) -> (Self::Output, Self::Output)
fn compare(&self, r: &R) -> Option<Ordering>
Source§impl Promote<i8> for Decimal
impl Promote<i8> for Decimal
type Output = Decimal
fn checked_promote(&self, r: &i8) -> Option<(Self::Output, Self::Output)>
fn saturating_promote(&self, r: &i8) -> (Self::Output, Self::Output)
fn wrapping_promote(&self, r: &i8) -> (Self::Output, Self::Output)
fn compare(&self, r: &R) -> Option<Ordering>
Source§impl Promote<i16> for Decimal
impl Promote<i16> for Decimal
type Output = Decimal
fn checked_promote(&self, r: &i16) -> Option<(Self::Output, Self::Output)>
fn saturating_promote(&self, r: &i16) -> (Self::Output, Self::Output)
fn wrapping_promote(&self, r: &i16) -> (Self::Output, Self::Output)
fn compare(&self, r: &R) -> Option<Ordering>
Source§impl Promote<i32> for Decimal
impl Promote<i32> for Decimal
type Output = Decimal
fn checked_promote(&self, r: &i32) -> Option<(Self::Output, Self::Output)>
fn saturating_promote(&self, r: &i32) -> (Self::Output, Self::Output)
fn wrapping_promote(&self, r: &i32) -> (Self::Output, Self::Output)
fn compare(&self, r: &R) -> Option<Ordering>
Source§impl Promote<i64> for Decimal
impl Promote<i64> for Decimal
type Output = Decimal
fn checked_promote(&self, r: &i64) -> Option<(Self::Output, Self::Output)>
fn saturating_promote(&self, r: &i64) -> (Self::Output, Self::Output)
fn wrapping_promote(&self, r: &i64) -> (Self::Output, Self::Output)
fn compare(&self, r: &R) -> Option<Ordering>
Source§impl Promote<i128> for Decimal
impl Promote<i128> for Decimal
type Output = Decimal
fn checked_promote(&self, r: &i128) -> Option<(Self::Output, Self::Output)>
fn saturating_promote(&self, r: &i128) -> (Self::Output, Self::Output)
fn wrapping_promote(&self, r: &i128) -> (Self::Output, Self::Output)
fn compare(&self, r: &R) -> Option<Ordering>
Source§impl Promote<u8> for Decimal
impl Promote<u8> for Decimal
type Output = Decimal
fn checked_promote(&self, r: &u8) -> Option<(Self::Output, Self::Output)>
fn saturating_promote(&self, r: &u8) -> (Self::Output, Self::Output)
fn wrapping_promote(&self, r: &u8) -> (Self::Output, Self::Output)
fn compare(&self, r: &R) -> Option<Ordering>
Source§impl Promote<u16> for Decimal
impl Promote<u16> for Decimal
type Output = Decimal
fn checked_promote(&self, r: &u16) -> Option<(Self::Output, Self::Output)>
fn saturating_promote(&self, r: &u16) -> (Self::Output, Self::Output)
fn wrapping_promote(&self, r: &u16) -> (Self::Output, Self::Output)
fn compare(&self, r: &R) -> Option<Ordering>
Source§impl Promote<u32> for Decimal
impl Promote<u32> for Decimal
type Output = Decimal
fn checked_promote(&self, r: &u32) -> Option<(Self::Output, Self::Output)>
fn saturating_promote(&self, r: &u32) -> (Self::Output, Self::Output)
fn wrapping_promote(&self, r: &u32) -> (Self::Output, Self::Output)
fn compare(&self, r: &R) -> Option<Ordering>
Source§impl Promote<u64> for Decimal
impl Promote<u64> for Decimal
type Output = Decimal
fn checked_promote(&self, r: &u64) -> Option<(Self::Output, Self::Output)>
fn saturating_promote(&self, r: &u64) -> (Self::Output, Self::Output)
fn wrapping_promote(&self, r: &u64) -> (Self::Output, Self::Output)
fn compare(&self, r: &R) -> Option<Ordering>
Source§impl Promote<u128> for Decimal
impl Promote<u128> for Decimal
type Output = Decimal
fn checked_promote(&self, r: &u128) -> Option<(Self::Output, Self::Output)>
fn saturating_promote(&self, r: &u128) -> (Self::Output, Self::Output)
fn wrapping_promote(&self, r: &u128) -> (Self::Output, Self::Output)
fn compare(&self, r: &R) -> Option<Ordering>
Source§impl SafeAdd for Decimal
impl SafeAdd for Decimal
fn checked_add(&self, r: &Self) -> Option<Self>
fn saturating_add(&self, r: &Self) -> Self
fn wrapping_add(&self, r: &Self) -> Self
Source§impl SafeConvert<Decimal> for Decimal
impl SafeConvert<Decimal> for Decimal
fn checked_convert(self) -> Option<Decimal>
fn saturating_convert(self) -> Decimal
fn wrapping_convert(self) -> Decimal
Source§impl SafeConvert<Decimal> for f32
impl SafeConvert<Decimal> for f32
fn checked_convert(self) -> Option<Decimal>
fn saturating_convert(self) -> Decimal
fn wrapping_convert(self) -> Decimal
Source§impl SafeConvert<Decimal> for f64
impl SafeConvert<Decimal> for f64
fn checked_convert(self) -> Option<Decimal>
fn saturating_convert(self) -> Decimal
fn wrapping_convert(self) -> Decimal
Source§impl SafeConvert<Decimal> for i128
impl SafeConvert<Decimal> for i128
fn checked_convert(self) -> Option<Decimal>
fn saturating_convert(self) -> Decimal
fn wrapping_convert(self) -> Decimal
Source§impl SafeConvert<Decimal> for i16
impl SafeConvert<Decimal> for i16
fn checked_convert(self) -> Option<Decimal>
fn saturating_convert(self) -> Decimal
fn wrapping_convert(self) -> Decimal
Source§impl SafeConvert<Decimal> for i32
impl SafeConvert<Decimal> for i32
fn checked_convert(self) -> Option<Decimal>
fn saturating_convert(self) -> Decimal
fn wrapping_convert(self) -> Decimal
Source§impl SafeConvert<Decimal> for i64
impl SafeConvert<Decimal> for i64
fn checked_convert(self) -> Option<Decimal>
fn saturating_convert(self) -> Decimal
fn wrapping_convert(self) -> Decimal
Source§impl SafeConvert<Decimal> for i8
impl SafeConvert<Decimal> for i8
fn checked_convert(self) -> Option<Decimal>
fn saturating_convert(self) -> Decimal
fn wrapping_convert(self) -> Decimal
Source§impl SafeConvert<Decimal> for u128
impl SafeConvert<Decimal> for u128
fn checked_convert(self) -> Option<Decimal>
fn saturating_convert(self) -> Decimal
fn wrapping_convert(self) -> Decimal
Source§impl SafeConvert<Decimal> for u16
impl SafeConvert<Decimal> for u16
fn checked_convert(self) -> Option<Decimal>
fn saturating_convert(self) -> Decimal
fn wrapping_convert(self) -> Decimal
Source§impl SafeConvert<Decimal> for u32
impl SafeConvert<Decimal> for u32
fn checked_convert(self) -> Option<Decimal>
fn saturating_convert(self) -> Decimal
fn wrapping_convert(self) -> Decimal
Source§impl SafeConvert<Decimal> for u64
impl SafeConvert<Decimal> for u64
fn checked_convert(self) -> Option<Decimal>
fn saturating_convert(self) -> Decimal
fn wrapping_convert(self) -> Decimal
Source§impl SafeConvert<Decimal> for u8
impl SafeConvert<Decimal> for u8
fn checked_convert(self) -> Option<Decimal>
fn saturating_convert(self) -> Decimal
fn wrapping_convert(self) -> Decimal
Source§impl SafeConvert<f32> for Decimal
impl SafeConvert<f32> for Decimal
fn checked_convert(self) -> Option<f32>
fn saturating_convert(self) -> f32
fn wrapping_convert(self) -> f32
Source§impl SafeConvert<f64> for Decimal
impl SafeConvert<f64> for Decimal
fn checked_convert(self) -> Option<f64>
fn saturating_convert(self) -> f64
fn wrapping_convert(self) -> f64
Source§impl SafeConvert<i8> for Decimal
impl SafeConvert<i8> for Decimal
fn checked_convert(self) -> Option<i8>
fn saturating_convert(self) -> i8
fn wrapping_convert(self) -> i8
Source§impl SafeConvert<i16> for Decimal
impl SafeConvert<i16> for Decimal
fn checked_convert(self) -> Option<i16>
fn saturating_convert(self) -> i16
fn wrapping_convert(self) -> i16
Source§impl SafeConvert<i32> for Decimal
impl SafeConvert<i32> for Decimal
fn checked_convert(self) -> Option<i32>
fn saturating_convert(self) -> i32
fn wrapping_convert(self) -> i32
Source§impl SafeConvert<i64> for Decimal
impl SafeConvert<i64> for Decimal
fn checked_convert(self) -> Option<i64>
fn saturating_convert(self) -> i64
fn wrapping_convert(self) -> i64
Source§impl SafeConvert<i128> for Decimal
impl SafeConvert<i128> for Decimal
fn checked_convert(self) -> Option<i128>
fn saturating_convert(self) -> i128
fn wrapping_convert(self) -> i128
Source§impl SafeConvert<u8> for Decimal
impl SafeConvert<u8> for Decimal
fn checked_convert(self) -> Option<u8>
fn saturating_convert(self) -> u8
fn wrapping_convert(self) -> u8
Source§impl SafeConvert<u16> for Decimal
impl SafeConvert<u16> for Decimal
fn checked_convert(self) -> Option<u16>
fn saturating_convert(self) -> u16
fn wrapping_convert(self) -> u16
Source§impl SafeConvert<u32> for Decimal
impl SafeConvert<u32> for Decimal
fn checked_convert(self) -> Option<u32>
fn saturating_convert(self) -> u32
fn wrapping_convert(self) -> u32
Source§impl SafeConvert<u64> for Decimal
impl SafeConvert<u64> for Decimal
fn checked_convert(self) -> Option<u64>
fn saturating_convert(self) -> u64
fn wrapping_convert(self) -> u64
Source§impl SafeConvert<u128> for Decimal
impl SafeConvert<u128> for Decimal
fn checked_convert(self) -> Option<u128>
fn saturating_convert(self) -> u128
fn wrapping_convert(self) -> u128
Source§impl SafeDiv for Decimal
impl SafeDiv for Decimal
fn checked_div(&self, r: &Self) -> Option<Self>
fn saturating_div(&self, r: &Self) -> Self
fn wrapping_div(&self, r: &Self) -> Self
fn is_zero(&self) -> bool
Source§impl SafeMul for Decimal
impl SafeMul for Decimal
fn checked_mul(&self, r: &Self) -> Option<Self>
fn saturating_mul(&self, r: &Self) -> Self
fn wrapping_mul(&self, r: &Self) -> Self
Source§impl SafeRemainder for Decimal
impl SafeRemainder for Decimal
fn checked_rem(&self, r: &Self) -> Option<Self>
fn saturating_rem(&self, r: &Self) -> Self
fn wrapping_rem(&self, r: &Self) -> Self
fn is_zero(&self) -> bool
Source§impl SafeSub for Decimal
impl SafeSub for Decimal
fn checked_sub(&self, r: &Self) -> Option<Self>
fn saturating_sub(&self, r: &Self) -> Self
fn wrapping_sub(&self, r: &Self) -> Self
Source§impl TryFromValue for Decimal
impl TryFromValue for Decimal
fn try_from_value(value: &Value) -> Result<Self, FromValueError>
fn from_value(value: &Value) -> Option<Self>
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§
impl<T> Allocation for T
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