Decimal

Struct Decimal 

Source
#[repr(transparent)]
pub struct Decimal(pub BigDecimal);

Tuple Fields§

§0: BigDecimal

Implementations§

Source§

impl Decimal

Source

pub fn zero() -> Self

Source

pub fn one() -> Self

Source§

impl Decimal

Source

pub fn new(value: BigDecimalInner) -> Self

Source

pub fn from_bigdecimal(value: BigDecimalInner) -> Self

Source

pub fn with_scale(value: BigDecimalInner, scale: i64) -> Self

Source

pub fn from_i64(value: i64) -> Self

Source

pub fn inner(&self) -> &BigDecimalInner

Source

pub fn to_bigdecimal(self) -> BigDecimalInner

Source

pub fn negate(self) -> Self

Methods from Deref<Target = BigDecimalInner>§

Source

pub fn to_ref(&self) -> BigDecimalRef<'_>

Make a BigDecimalRef of this value

Source

pub fn decimal_digit_count(&self) -> u64

Count of decimal digits

Zero is considered to be one digit.

Source

pub fn order_of_magnitude(&self) -> i64

Position of most significant digit of this decimal

Equivalent to the exponent when written in scientific notation, or ⌊log10(n)⌋.

The order of magnitude of 0 is 0.

Source

pub fn fractional_digit_count(&self) -> i64

Returns the scale of the BigDecimal, the total number of digits to the right of the decimal point (including insignificant leading zeros)

§Examples
use bigdecimal::BigDecimal;
use std::str::FromStr;

let a = BigDecimal::from(12345);  // No fractional part
let b = BigDecimal::from_str("123.45").unwrap();  // Fractional part
let c = BigDecimal::from_str("0.0000012345").unwrap();  // Completely fractional part
let d = BigDecimal::from_str("5e9").unwrap();  // Negative-fractional part

assert_eq!(a.fractional_digit_count(), 0);
assert_eq!(b.fractional_digit_count(), 2);
assert_eq!(c.fractional_digit_count(), 10);
assert_eq!(d.fractional_digit_count(), -9);
Source

pub fn with_scale(&self, new_scale: i64) -> BigDecimal

Return a new BigDecimal object equivalent to self, with internal scaling set to the number specified. If the new_scale is lower than the current value (indicating a larger power of 10), digits will be dropped (as precision is lower)

Source

pub fn with_scale_round(&self, new_scale: i64, mode: RoundingMode) -> BigDecimal

Return a new BigDecimal after shortening the digits and rounding


let n: BigDecimal = "129.41675".parse().unwrap();

assert_eq!(n.with_scale_round(2, RoundingMode::Up),  "129.42".parse().unwrap());
assert_eq!(n.with_scale_round(-1, RoundingMode::Down),  "120".parse().unwrap());
assert_eq!(n.with_scale_round(4, RoundingMode::HalfEven),  "129.4168".parse().unwrap());
Source

pub fn with_prec(&self, prec: u64) -> BigDecimal

Return a new BigDecimal object with precision set to new value


let n: BigDecimal = "129.41675".parse().unwrap();

assert_eq!(n.with_prec(2),  "130".parse().unwrap());

let n_p12 = n.with_prec(12);
let (i, scale) = n_p12.as_bigint_and_exponent();
assert_eq!(n_p12, "129.416750000".parse().unwrap());
assert_eq!(i, 129416750000_u64.into());
assert_eq!(scale, 9);
Source

pub fn with_precision_round( &self, prec: NonZero<u64>, round: RoundingMode, ) -> BigDecimal

Return this BigDecimal with the given precision, rounding if needed

Source

pub fn sign(&self) -> Sign

Return the sign of the BigDecimal as num::bigint::Sign.


fn sign_of(src: &str) -> Sign {
   let n: BigDecimal = src.parse().unwrap();
   n.sign()
}

assert_eq!(sign_of("-1"), Sign::Minus);
assert_eq!(sign_of("0"),  Sign::NoSign);
assert_eq!(sign_of("1"),  Sign::Plus);
Source

pub fn as_bigint_and_exponent(&self) -> (BigInt, i64)

Return the internal big integer value and an exponent. Note that a positive exponent indicates a negative power of 10.

§Examples
use bigdecimal::{BigDecimal, num_bigint::BigInt};

let n: BigDecimal = "1.23456".parse().unwrap();
let expected = ("123456".parse::<BigInt>().unwrap(), 5);
assert_eq!(n.as_bigint_and_exponent(), expected);
Source

pub fn as_bigint_and_scale(&self) -> (Cow<'_, BigInt>, i64)

Return digits as borrowed Cow of integer digits, and its scale

Scale is number of digits after the decimal point, can be negative.

Source

pub fn digits(&self) -> u64

Number of digits in the non-scaled integer representation

Source

pub fn abs(&self) -> BigDecimal

Compute the absolute value of number

let n: BigDecimal = "123.45".parse().unwrap();
assert_eq!(n.abs(), "123.45".parse().unwrap());

let n: BigDecimal = "-123.45".parse().unwrap();
assert_eq!(n.abs(), "123.45".parse().unwrap());
Source

pub fn double(&self) -> BigDecimal

Multiply decimal by 2 (efficiently)

let n: BigDecimal = "123.45".parse().unwrap();
assert_eq!(n.double(), "246.90".parse().unwrap());
Source

pub fn half(&self) -> BigDecimal

Divide decimal by 2 (efficiently)

Note: If the last digit in the decimal is odd, the precision will increase by 1

let n: BigDecimal = "123.45".parse().unwrap();
assert_eq!(n.half(), "61.725".parse().unwrap());
Source

pub fn square(&self) -> BigDecimal

Square a decimal:

No rounding or truncating of digits; this is the full result of the squaring operation.

Note: doubles the scale of bigdecimal, which might lead to accidental exponential-complexity if used in a loop.

let n: BigDecimal = "1.1156024145937225657484".parse().unwrap();
assert_eq!(n.square(), "1.24456874744734405154288399835406316085210256".parse().unwrap());

let n: BigDecimal = "-9.238597585E+84".parse().unwrap();
assert_eq!(n.square(), "8.5351685337567832225E+169".parse().unwrap());
Source

pub fn cube(&self) -> BigDecimal

Cube a decimal:

No rounding or truncating of digits; this is the full result of the cubing operation.

Note: triples the scale of bigdecimal, which might lead to accidental exponential-complexity if used in a loop.

let n: BigDecimal = "1.1156024145937225657484".parse().unwrap();
assert_eq!(n.cube(), "1.388443899780141911774491376394890472130000455312878627147979955904".parse().unwrap());

let n: BigDecimal = "-9.238597585E+84".parse().unwrap();
assert_eq!(n.cube(), "-7.88529874035334084567570176625E+254".parse().unwrap());
Source

pub fn powi(&self, exp: i64) -> BigDecimal

Raises the number to an integer power

Uses default-precision, set from build time environment variable

let n: BigDecimal = 2.into();
assert_eq!(n.powi(3000000000), "9.816204233623505350831385407878283564899139328691307267002649220552261820356883420275966921502700387e903089986".parse().unwrap());
Source

pub fn powi_with_context(&self, exp: i64, ctx: &Context) -> BigDecimal

Raises the number to an integer power, using context for precision and rounding

Source

pub fn sqrt(&self) -> Option<BigDecimal>

Take the square root of the number

Uses default-precision, set from build time environment variable

If the value is < 0, None is returned

let n: BigDecimal = "1.1156024145937225657484".parse().unwrap();
assert_eq!(n.sqrt().unwrap(), "1.056220817156016181190291268045893004363809142172289919023269377496528394924695970851558013658193913".parse().unwrap());

let n: BigDecimal = "-9.238597585E+84".parse().unwrap();
assert_eq!(n.sqrt(), None);
Source

pub fn sqrt_with_context(&self, ctx: &Context) -> Option<BigDecimal>

Take the square root of the number, using context for precision and rounding

Source

pub fn cbrt(&self) -> BigDecimal

Take the cube root of the number, using default context

Source

pub fn cbrt_with_context(&self, ctx: &Context) -> BigDecimal

Take cube root of self, using properties of context

Source

pub fn inverse(&self) -> BigDecimal

Compute the reciprical of the number: x-1

Source

pub fn inverse_with_context(&self, ctx: &Context) -> BigDecimal

Return inverse of self, rounding with ctx

Source

pub fn mul_with_context<'a, T>(&'a self, rhs: T, ctx: &Context) -> BigDecimal
where T: Into<BigDecimalRef<'a>>,

Multiply by rhs, limiting precision using context

Source

pub fn round(&self, round_digits: i64) -> BigDecimal

Return given number rounded to ‘round_digits’ precision after the decimal point, using default rounding mode

Default rounding mode is HalfEven, but can be configured at compile-time by the environment variable: RUST_BIGDECIMAL_DEFAULT_ROUNDING_MODE (or by patching build.rs )

Source

pub fn is_integer(&self) -> bool

Return true if this number has zero fractional part (is equal to an integer)

Source

pub fn is_one_quickcheck(&self) -> Option<bool>

Try to determine if decimal is 1.0, without allocating

Source

pub fn exp(&self) -> BigDecimal

Evaluate the natural-exponential function ex

Source

pub fn normalized(&self) -> BigDecimal

Source

pub fn to_plain_string(&self) -> String

Create string of decimal in standard decimal notation.

Unlike standard formatter, this never prints the number in scientific notation.

§Panics

If the magnitude of the exponent is very large, this may cause out-of-memory errors, or overflowing panics.

§Examples
let n: BigDecimal = "123.45678".parse().unwrap();
assert_eq!(&n.to_plain_string(), "123.45678");

let n: BigDecimal = "1e-10".parse().unwrap();
assert_eq!(&n.to_plain_string(), "0.0000000001");
Source

pub fn write_plain_string<W>(&self, wtr: &mut W) -> Result<(), Error>
where W: Write,

Write decimal value in decimal notation to the writer object.

§Panics

If the exponent is very large or very small, the number of this will print that many trailing or leading zeros. If exabytes, this will likely panic.

Source

pub fn to_scientific_notation(&self) -> String

Create string of this bigdecimal in scientific notation

let n = BigDecimal::from(12345678);
assert_eq!(&n.to_scientific_notation(), "1.2345678e7");
Source

pub fn write_scientific_notation<W>(&self, w: &mut W) -> Result<(), Error>
where W: Write,

Write bigdecimal in scientific notation to writer w

Source

pub fn to_engineering_notation(&self) -> String

Create string of this bigdecimal in engineering notation

Engineering notation is scientific notation with the exponent coerced to a multiple of three

let n = BigDecimal::from(12345678);
assert_eq!(&n.to_engineering_notation(), "12.345678e6");
Source

pub fn write_engineering_notation<W>(&self, w: &mut W) -> Result<(), Error>
where W: Write,

Write bigdecimal in engineering notation to writer w

Trait Implementations§

Source§

impl Clone for Decimal

Source§

fn clone(&self) -> Decimal

Returns a duplicate of the value. Read more
1.0.0§

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 Deref for Decimal

Source§

type Target = BigDecimal

The resulting type after dereferencing.
Source§

fn deref(&self) -> &Self::Target

Dereferences the value.
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 From<BigDecimal> for Decimal

Source§

fn from(value: BigDecimalInner) -> Self

Converts to this type from the input type.
Source§

impl From<Int> for Decimal

Source§

fn from(value: Int) -> Self

Converts to this type from the input type.
Source§

impl From<Uint> for Decimal

Source§

fn from(value: Uint) -> Self

Converts to this type from the input type.
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<i128> for Decimal

Source§

fn from(value: i128) -> 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<i8> for Decimal

Source§

fn from(value: i8) -> 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 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<u8> for Decimal

Source§

fn from(value: u8) -> Self

Converts to this type from the input type.
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§

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 Ord for Decimal

Source§

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

This method returns an Ordering between self and other. Read more
1.21.0§

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

Compares and returns the maximum of two values. Read more
1.21.0§

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

Compares and returns the minimum of two values. Read more
1.50.0§

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

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

impl PartialEq for Decimal

Source§

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

Tests for self and other values to be equal, and is used by ==.
1.0.0§

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

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
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§

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

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

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§

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

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

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§

impl Promote<Decimal> for Int

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§

impl Promote<Decimal> for Uint

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§

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§

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§

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§

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§

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§

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§

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§

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§

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§

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§

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§

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§

impl Promote<Int> for Decimal

Source§

type Output = Decimal

Source§

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

Source§

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

Source§

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

Source§

impl Promote<Uint> for Decimal

Source§

type Output = Decimal

Source§

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

Source§

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

Source§

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

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§

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§

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§

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§

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§

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§

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§

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§

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§

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§

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§

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§

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 Int

Source§

impl SafeConvert<Decimal> for Uint

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<Int> for Decimal

Source§

impl SafeConvert<Uint> for Decimal

Source§

impl SafeConvert<f32> for Decimal

Source§

impl SafeConvert<f64> for Decimal

Source§

impl SafeConvert<i128> for Decimal

Source§

impl SafeConvert<i16> for Decimal

Source§

impl SafeConvert<i32> for Decimal

Source§

impl SafeConvert<i64> for Decimal

Source§

impl SafeConvert<i8> for Decimal

Source§

impl SafeConvert<u128> for Decimal

Source§

impl SafeConvert<u16> for Decimal

Source§

impl SafeConvert<u32> for Decimal

Source§

impl SafeConvert<u64> for Decimal

Source§

impl SafeConvert<u8> 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§

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§

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 TryFromValue for Decimal

Source§

fn try_from_value(value: &Value) -> Result<Self, FromValueError>

Attempt to extract a value of this type from a Value. Read more
Source§

fn from_value(value: &Value) -> Option<Self>

Extract from Value, returning None for Undefined or type mismatch. Read more
Source§

impl Eq for Decimal

Source§

impl IsFloat for Decimal

Source§

impl IsNumber for Decimal

Auto Trait Implementations§

Blanket Implementations§

§

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

§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
§

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

§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
§

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

§

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

Mutably borrows from an owned value. Read more
§

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

§

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
§

impl<T> From<T> for T

§

fn from(t: T) -> T

Returns the argument unchanged.

§

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

§

fn into(self) -> U

Calls U::from(self).

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

§

impl<P, T> Receiver for P
where P: Deref<Target = T> + ?Sized, T: ?Sized,

§

type Target = T

🔬This is a nightly-only experimental API. (arbitrary_self_types)
The target type on which the method may be called.
§

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

§

type Owned = T

The resulting type after obtaining ownership.
§

fn to_owned(&self) -> T

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

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

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

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

§

fn to_string(&self) -> String

Converts the given value to a String. Read more
§

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

§

type Error = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
§

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

§

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

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

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

Performs the conversion.
Source§

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