Skip to main content

Decimal

Struct Decimal 

Source
pub struct Decimal { /* private fields */ }

Implementations§

Source§

impl Decimal

Source

pub const MAX_SCALE: u8 = MAX_DIGITS

Source

pub fn from_parts(unscaled: i256, scale: u8) -> Option<Self>

Source

pub fn parse(text: &str) -> Result<Self, ParseError>

Source

pub fn zero() -> Self

Source

pub fn one() -> Self

Source

pub fn from_i64(value: i64) -> Self

Source

pub fn from_i128(value: i128) -> Self

Source

pub fn from_u128(value: u128) -> Self

Source

pub fn from_f64(value: f64) -> Option<Self>

Source

pub fn from_f32(value: f32) -> Option<Self>

Source

pub fn saturated(negative: bool, scale: u8) -> Self

Source

pub fn unscaled(&self) -> i256

Source

pub fn scale(&self) -> u8

Source

pub fn digits(&self) -> u8

Source

pub fn is_zero(&self) -> bool

Source

pub fn is_negative(&self) -> bool

Source

pub fn negate(&self) -> Self

Source

pub fn abs(&self) -> Self

Source

pub fn trunc(&self) -> i256

Source

pub fn ceil(&self) -> i256

Source

pub fn floor(&self) -> i256

Source

pub fn to_f64(&self) -> f64

Source

pub fn to_f32(&self) -> f32

Source

pub fn rescale(&self, scale: u8) -> Option<Self>

Source

pub fn round_to_scale(&self, scale: u8) -> Option<Self>

Source

pub fn fits(&self, precision: u8, scale: u8) -> Option<Self>

Source

pub fn checked_add(&self, other: &Self) -> Option<Self>

Source

pub fn checked_sub(&self, other: &Self) -> Option<Self>

Source

pub fn checked_mul(&self, other: &Self) -> Option<Self>

Source

pub fn checked_pow(&self, exp: u32) -> Option<Self>

Source

pub fn checked_div(&self, other: &Self) -> Option<Self>

Source

pub fn checked_rem(&self, other: &Self) -> Option<Self>

Source

pub fn saturating_add(&self, other: &Self) -> Self

Source

pub fn saturating_sub(&self, other: &Self) -> Self

Source

pub fn saturating_mul(&self, other: &Self) -> Self

Source

pub fn saturating_div(&self, other: &Self) -> Self

Source

pub fn saturating_rem(&self, other: &Self) -> Self

Trait Implementations§

Source§

impl Clone for Decimal

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Decimal

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for Decimal

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl<'de> Deserialize<'de> for Decimal

Source§

fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
where D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Display for Decimal

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Eq for Decimal

Source§

impl From<f32> for Decimal

Source§

fn from(value: f32) -> Self

Converts to this type from the input type.
Source§

impl From<f64> for Decimal

Source§

fn from(value: f64) -> Self

Converts to this type from the input type.
Source§

impl From<i8> for Decimal

Source§

fn from(value: i8) -> Self

Converts to this type from the input type.
Source§

impl From<i16> for Decimal

Source§

fn from(value: i16) -> Self

Converts to this type from the input type.
Source§

impl From<i32> for Decimal

Source§

fn from(value: i32) -> Self

Converts to this type from the input type.
Source§

impl From<i64> for Decimal

Source§

fn from(value: i64) -> Self

Converts to this type from the input type.
Source§

impl From<i128> for Decimal

Source§

fn from(value: i128) -> Self

Converts to this type from the input type.
Source§

impl From<u8> for Decimal

Source§

fn from(value: u8) -> Self

Converts to this type from the input type.
Source§

impl From<u16> for Decimal

Source§

fn from(value: u16) -> Self

Converts to this type from the input type.
Source§

impl From<u32> for Decimal

Source§

fn from(value: u32) -> Self

Converts to this type from the input type.
Source§

impl From<u64> for Decimal

Source§

fn from(value: u64) -> Self

Converts to this type from the input type.
Source§

impl From<u128> for Decimal

Source§

fn from(value: u128) -> Self

Converts to this type from the input type.
Source§

impl FromColumnView for Decimal

Source§

impl FromStr for Decimal

Source§

type Err = Error

The associated error which can be returned from parsing.
Source§

fn from_str(s: &str) -> Result<Self, Self::Err>

Parses a string s to return a value of this type. Read more
Source§

impl GetType for Decimal

Source§

impl Hash for Decimal

Source§

fn hash<H: Hasher>(&self, state: &mut H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl IsFloat for Decimal

Source§

impl IsNumber for Decimal

Source§

impl Ord for Decimal

Source§

fn cmp(&self, other: &Self) -> Ordering

This method returns an Ordering between self and other. Read more
1.21.0 (const: unstable) · Source§

fn max(self, other: Self) -> Self
where Self: Sized,

Compares and returns the maximum of two values. Read more
1.21.0 (const: unstable) · Source§

fn min(self, other: Self) -> Self
where Self: Sized,

Compares and returns the minimum of two values. Read more
1.50.0 (const: unstable) · Source§

fn clamp(self, min: Self, max: Self) -> Self
where Self: Sized,

Restrict a value to a certain interval. Read more
Source§

fn clamp_to<R>(self, range: R) -> Self
where Self: Sized, R: ClampBounds<Self>,

🔬This is a nightly-only experimental API. (clamp_to)
Restrict a value to a certain range. Read more
Source§

impl PartialEq for Decimal

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl PartialOrd for Decimal

Source§

fn partial_cmp(&self, other: &Self) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 (const: unstable) · Source§

fn lt(&self, other: &Rhs) -> bool

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 (const: unstable) · Source§

fn le(&self, other: &Rhs) -> bool

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 (const: unstable) · Source§

fn gt(&self, other: &Rhs) -> bool

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 (const: unstable) · Source§

fn ge(&self, other: &Rhs) -> bool

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Source§

impl Promote<Decimal> for Decimal

Source§

type Output = Decimal

Source§

fn checked_promote(&self, r: &Decimal) -> Option<(Self::Output, Self::Output)>

Source§

fn saturating_promote(&self, r: &Decimal) -> (Self::Output, Self::Output)

Source§

fn wrapping_promote(&self, r: &Decimal) -> (Self::Output, Self::Output)

Source§

fn compare(&self, r: &R) -> Option<Ordering>

Source§

impl Promote<Decimal> for f32

Source§

type Output = Decimal

Source§

fn checked_promote(&self, r: &Decimal) -> Option<(Self::Output, Self::Output)>

Source§

fn saturating_promote(&self, r: &Decimal) -> (Self::Output, Self::Output)

Source§

fn wrapping_promote(&self, r: &Decimal) -> (Self::Output, Self::Output)

Source§

fn compare(&self, r: &R) -> Option<Ordering>

Source§

impl Promote<Decimal> for f64

Source§

type Output = Decimal

Source§

fn checked_promote(&self, r: &Decimal) -> Option<(Self::Output, Self::Output)>

Source§

fn saturating_promote(&self, r: &Decimal) -> (Self::Output, Self::Output)

Source§

fn wrapping_promote(&self, r: &Decimal) -> (Self::Output, Self::Output)

Source§

fn compare(&self, r: &R) -> Option<Ordering>

Source§

impl Promote<Decimal> for i8

Source§

type Output = Decimal

Source§

fn checked_promote(&self, r: &Decimal) -> Option<(Self::Output, Self::Output)>

Source§

fn saturating_promote(&self, r: &Decimal) -> (Self::Output, Self::Output)

Source§

fn wrapping_promote(&self, r: &Decimal) -> (Self::Output, Self::Output)

Source§

fn compare(&self, r: &R) -> Option<Ordering>

Source§

impl Promote<Decimal> for i16

Source§

type Output = Decimal

Source§

fn checked_promote(&self, r: &Decimal) -> Option<(Self::Output, Self::Output)>

Source§

fn saturating_promote(&self, r: &Decimal) -> (Self::Output, Self::Output)

Source§

fn wrapping_promote(&self, r: &Decimal) -> (Self::Output, Self::Output)

Source§

fn compare(&self, r: &R) -> Option<Ordering>

Source§

impl Promote<Decimal> for i32

Source§

type Output = Decimal

Source§

fn checked_promote(&self, r: &Decimal) -> Option<(Self::Output, Self::Output)>

Source§

fn saturating_promote(&self, r: &Decimal) -> (Self::Output, Self::Output)

Source§

fn wrapping_promote(&self, r: &Decimal) -> (Self::Output, Self::Output)

Source§

fn compare(&self, r: &R) -> Option<Ordering>

Source§

impl Promote<Decimal> for i64

Source§

type Output = Decimal

Source§

fn checked_promote(&self, r: &Decimal) -> Option<(Self::Output, Self::Output)>

Source§

fn saturating_promote(&self, r: &Decimal) -> (Self::Output, Self::Output)

Source§

fn wrapping_promote(&self, r: &Decimal) -> (Self::Output, Self::Output)

Source§

fn compare(&self, r: &R) -> Option<Ordering>

Source§

impl Promote<Decimal> for i128

Source§

type Output = Decimal

Source§

fn checked_promote(&self, r: &Decimal) -> Option<(Self::Output, Self::Output)>

Source§

fn saturating_promote(&self, r: &Decimal) -> (Self::Output, Self::Output)

Source§

fn wrapping_promote(&self, r: &Decimal) -> (Self::Output, Self::Output)

Source§

fn compare(&self, r: &R) -> Option<Ordering>

Source§

impl Promote<Decimal> for u8

Source§

type Output = Decimal

Source§

fn checked_promote(&self, r: &Decimal) -> Option<(Self::Output, Self::Output)>

Source§

fn saturating_promote(&self, r: &Decimal) -> (Self::Output, Self::Output)

Source§

fn wrapping_promote(&self, r: &Decimal) -> (Self::Output, Self::Output)

Source§

fn compare(&self, r: &R) -> Option<Ordering>

Source§

impl Promote<Decimal> for u16

Source§

type Output = Decimal

Source§

fn checked_promote(&self, r: &Decimal) -> Option<(Self::Output, Self::Output)>

Source§

fn saturating_promote(&self, r: &Decimal) -> (Self::Output, Self::Output)

Source§

fn wrapping_promote(&self, r: &Decimal) -> (Self::Output, Self::Output)

Source§

fn compare(&self, r: &R) -> Option<Ordering>

Source§

impl Promote<Decimal> for u32

Source§

type Output = Decimal

Source§

fn checked_promote(&self, r: &Decimal) -> Option<(Self::Output, Self::Output)>

Source§

fn saturating_promote(&self, r: &Decimal) -> (Self::Output, Self::Output)

Source§

fn wrapping_promote(&self, r: &Decimal) -> (Self::Output, Self::Output)

Source§

fn compare(&self, r: &R) -> Option<Ordering>

Source§

impl Promote<Decimal> for u64

Source§

type Output = Decimal

Source§

fn checked_promote(&self, r: &Decimal) -> Option<(Self::Output, Self::Output)>

Source§

fn saturating_promote(&self, r: &Decimal) -> (Self::Output, Self::Output)

Source§

fn wrapping_promote(&self, r: &Decimal) -> (Self::Output, Self::Output)

Source§

fn compare(&self, r: &R) -> Option<Ordering>

Source§

impl Promote<Decimal> for u128

Source§

type Output = Decimal

Source§

fn checked_promote(&self, r: &Decimal) -> Option<(Self::Output, Self::Output)>

Source§

fn saturating_promote(&self, r: &Decimal) -> (Self::Output, Self::Output)

Source§

fn wrapping_promote(&self, r: &Decimal) -> (Self::Output, Self::Output)

Source§

fn compare(&self, r: &R) -> Option<Ordering>

Source§

impl Promote<f32> for Decimal

Source§

type Output = Decimal

Source§

fn checked_promote(&self, r: &f32) -> Option<(Self::Output, Self::Output)>

Source§

fn saturating_promote(&self, r: &f32) -> (Self::Output, Self::Output)

Source§

fn wrapping_promote(&self, r: &f32) -> (Self::Output, Self::Output)

Source§

fn compare(&self, r: &R) -> Option<Ordering>

Source§

impl Promote<f64> for Decimal

Source§

type Output = Decimal

Source§

fn checked_promote(&self, r: &f64) -> Option<(Self::Output, Self::Output)>

Source§

fn saturating_promote(&self, r: &f64) -> (Self::Output, Self::Output)

Source§

fn wrapping_promote(&self, r: &f64) -> (Self::Output, Self::Output)

Source§

fn compare(&self, r: &R) -> Option<Ordering>

Source§

impl Promote<i8> for Decimal

Source§

type Output = Decimal

Source§

fn checked_promote(&self, r: &i8) -> Option<(Self::Output, Self::Output)>

Source§

fn saturating_promote(&self, r: &i8) -> (Self::Output, Self::Output)

Source§

fn wrapping_promote(&self, r: &i8) -> (Self::Output, Self::Output)

Source§

fn compare(&self, r: &R) -> Option<Ordering>

Source§

impl Promote<i16> for Decimal

Source§

type Output = Decimal

Source§

fn checked_promote(&self, r: &i16) -> Option<(Self::Output, Self::Output)>

Source§

fn saturating_promote(&self, r: &i16) -> (Self::Output, Self::Output)

Source§

fn wrapping_promote(&self, r: &i16) -> (Self::Output, Self::Output)

Source§

fn compare(&self, r: &R) -> Option<Ordering>

Source§

impl Promote<i32> for Decimal

Source§

type Output = Decimal

Source§

fn checked_promote(&self, r: &i32) -> Option<(Self::Output, Self::Output)>

Source§

fn saturating_promote(&self, r: &i32) -> (Self::Output, Self::Output)

Source§

fn wrapping_promote(&self, r: &i32) -> (Self::Output, Self::Output)

Source§

fn compare(&self, r: &R) -> Option<Ordering>

Source§

impl Promote<i64> for Decimal

Source§

type Output = Decimal

Source§

fn checked_promote(&self, r: &i64) -> Option<(Self::Output, Self::Output)>

Source§

fn saturating_promote(&self, r: &i64) -> (Self::Output, Self::Output)

Source§

fn wrapping_promote(&self, r: &i64) -> (Self::Output, Self::Output)

Source§

fn compare(&self, r: &R) -> Option<Ordering>

Source§

impl Promote<i128> for Decimal

Source§

type Output = Decimal

Source§

fn checked_promote(&self, r: &i128) -> Option<(Self::Output, Self::Output)>

Source§

fn saturating_promote(&self, r: &i128) -> (Self::Output, Self::Output)

Source§

fn wrapping_promote(&self, r: &i128) -> (Self::Output, Self::Output)

Source§

fn compare(&self, r: &R) -> Option<Ordering>

Source§

impl Promote<u8> for Decimal

Source§

type Output = Decimal

Source§

fn checked_promote(&self, r: &u8) -> Option<(Self::Output, Self::Output)>

Source§

fn saturating_promote(&self, r: &u8) -> (Self::Output, Self::Output)

Source§

fn wrapping_promote(&self, r: &u8) -> (Self::Output, Self::Output)

Source§

fn compare(&self, r: &R) -> Option<Ordering>

Source§

impl Promote<u16> for Decimal

Source§

type Output = Decimal

Source§

fn checked_promote(&self, r: &u16) -> Option<(Self::Output, Self::Output)>

Source§

fn saturating_promote(&self, r: &u16) -> (Self::Output, Self::Output)

Source§

fn wrapping_promote(&self, r: &u16) -> (Self::Output, Self::Output)

Source§

fn compare(&self, r: &R) -> Option<Ordering>

Source§

impl Promote<u32> for Decimal

Source§

type Output = Decimal

Source§

fn checked_promote(&self, r: &u32) -> Option<(Self::Output, Self::Output)>

Source§

fn saturating_promote(&self, r: &u32) -> (Self::Output, Self::Output)

Source§

fn wrapping_promote(&self, r: &u32) -> (Self::Output, Self::Output)

Source§

fn compare(&self, r: &R) -> Option<Ordering>

Source§

impl Promote<u64> for Decimal

Source§

type Output = Decimal

Source§

fn checked_promote(&self, r: &u64) -> Option<(Self::Output, Self::Output)>

Source§

fn saturating_promote(&self, r: &u64) -> (Self::Output, Self::Output)

Source§

fn wrapping_promote(&self, r: &u64) -> (Self::Output, Self::Output)

Source§

fn compare(&self, r: &R) -> Option<Ordering>

Source§

impl Promote<u128> for Decimal

Source§

type Output = Decimal

Source§

fn checked_promote(&self, r: &u128) -> Option<(Self::Output, Self::Output)>

Source§

fn saturating_promote(&self, r: &u128) -> (Self::Output, Self::Output)

Source§

fn wrapping_promote(&self, r: &u128) -> (Self::Output, Self::Output)

Source§

fn compare(&self, r: &R) -> Option<Ordering>

Source§

impl SafeAdd for Decimal

Source§

fn checked_add(&self, r: &Self) -> Option<Self>

Source§

fn saturating_add(&self, r: &Self) -> Self

Source§

fn wrapping_add(&self, r: &Self) -> Self

Source§

impl SafeConvert<Decimal> for Decimal

Source§

impl SafeConvert<Decimal> for f32

Source§

impl SafeConvert<Decimal> for f64

Source§

impl SafeConvert<Decimal> for i128

Source§

impl SafeConvert<Decimal> for i16

Source§

impl SafeConvert<Decimal> for i32

Source§

impl SafeConvert<Decimal> for i64

Source§

impl SafeConvert<Decimal> for i8

Source§

impl SafeConvert<Decimal> for u128

Source§

impl SafeConvert<Decimal> for u16

Source§

impl SafeConvert<Decimal> for u32

Source§

impl SafeConvert<Decimal> for u64

Source§

impl SafeConvert<Decimal> for u8

Source§

impl SafeConvert<f32> for Decimal

Source§

impl SafeConvert<f64> for Decimal

Source§

impl SafeConvert<i8> for Decimal

Source§

impl SafeConvert<i16> for Decimal

Source§

impl SafeConvert<i32> for Decimal

Source§

impl SafeConvert<i64> for Decimal

Source§

impl SafeConvert<i128> for Decimal

Source§

impl SafeConvert<u8> for Decimal

Source§

impl SafeConvert<u16> for Decimal

Source§

impl SafeConvert<u32> for Decimal

Source§

impl SafeConvert<u64> for Decimal

Source§

impl SafeConvert<u128> for Decimal

Source§

impl SafeDiv for Decimal

Source§

fn checked_div(&self, r: &Self) -> Option<Self>

Source§

fn saturating_div(&self, r: &Self) -> Self

Source§

fn wrapping_div(&self, r: &Self) -> Self

Source§

fn is_zero(&self) -> bool

Source§

impl SafeMul for Decimal

Source§

fn checked_mul(&self, r: &Self) -> Option<Self>

Source§

fn saturating_mul(&self, r: &Self) -> Self

Source§

fn wrapping_mul(&self, r: &Self) -> Self

Source§

impl SafeRemainder for Decimal

Source§

fn checked_rem(&self, r: &Self) -> Option<Self>

Source§

fn saturating_rem(&self, r: &Self) -> Self

Source§

fn wrapping_rem(&self, r: &Self) -> Self

Source§

fn is_zero(&self) -> bool

Source§

impl SafeSub for Decimal

Source§

fn checked_sub(&self, r: &Self) -> Option<Self>

Source§

fn saturating_sub(&self, r: &Self) -> Self

Source§

fn wrapping_sub(&self, r: &Self) -> Self

Source§

impl Serialize for Decimal

Source§

fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
where S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl ToValue for Decimal

Source§

fn to_value(&self) -> Value

Source§

impl TryFromValue for Decimal

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Allocation for T
where T: RefUnwindSafe + Send + Sync,

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.