Struct Decimal

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

Decimal represents a 128 bit representation of a fixed-precision decimal number. The finite set of values of type Decimal are of the form m / 10e, where m is an integer such that -296 < m < 296, and e is an integer between 0 and 28 inclusive.

Implementationsยง

Sourceยง

impl Decimal

Source

pub const MIN: Decimal = MIN

The smallest value that can be represented by this decimal type.

ยงExamples

Basic usage:

assert_eq!(Decimal::MIN, dec!(-79_228_162_514_264_337_593_543_950_335));
Source

pub const MAX: Decimal = MAX

The largest value that can be represented by this decimal type.

ยงExamples

Basic usage:

assert_eq!(Decimal::MAX, dec!(79_228_162_514_264_337_593_543_950_335));
Source

pub const ZERO: Decimal = ZERO

A constant representing 0.

ยงExamples

Basic usage:

assert_eq!(Decimal::ZERO, dec!(0));
Source

pub const ONE: Decimal = ONE

A constant representing 1.

ยงExamples

Basic usage:

assert_eq!(Decimal::ONE, dec!(1));
Source

pub const NEGATIVE_ONE: Decimal = NEGATIVE_ONE

A constant representing -1.

ยงExamples

Basic usage:

assert_eq!(Decimal::NEGATIVE_ONE, dec!(-1));
Source

pub const TWO: Decimal = TWO

A constant representing 2.

ยงExamples

Basic usage:

assert_eq!(Decimal::TWO, dec!(2));
Source

pub const TEN: Decimal = TEN

A constant representing 10.

ยงExamples

Basic usage:

assert_eq!(Decimal::TEN, dec!(10));
Source

pub const ONE_HUNDRED: Decimal = ONE_HUNDRED

A constant representing 100.

ยงExamples

Basic usage:

assert_eq!(Decimal::ONE_HUNDRED, dec!(100));
Source

pub const ONE_THOUSAND: Decimal = ONE_THOUSAND

A constant representing 1000.

ยงExamples

Basic usage:

assert_eq!(Decimal::ONE_THOUSAND, dec!(1000));
Source

pub const MAX_SCALE: u32 = 28u32

The maximum supported scale value.

Some operations, such as Self::rescale may accept larger scale values, but these operations will result in a final value with a scale no larger than this.

Note that the maximum scale is not the same as the maximum possible numeric precision in base-10.

Source

pub fn new(num: i64, scale: u32) -> Decimal

Returns a Decimal with a 64 bit m representation and corresponding e scale.

ยงArguments
  • num - An i64 that represents the m portion of the decimal number
  • scale - A u32 representing the e portion of the decimal number.
ยงPanics

This function panics if scale is > Self::MAX_SCALE.

ยงExample
let pi = Decimal::new(3141, 3);
assert_eq!(pi.to_string(), "3.141");
Source

pub const fn try_new(num: i64, scale: u32) -> Result<Decimal, Error>

Checked version of Self::new. Will return an error instead of panicking at run-time.

ยงExample
let max = Decimal::try_new(i64::MAX, u32::MAX);
assert!(max.is_err());
Source

pub fn from_i128_with_scale(num: i128, scale: u32) -> Decimal

Creates a Decimal using a 128 bit signed m representation and corresponding e scale.

ยงArguments
  • num - An i128 that represents the m portion of the decimal number
  • scale - A u32 representing the e portion of the decimal number.
ยงPanics

This function panics if scale is > Self::MAX_SCALE or if num exceeds the maximum supported 96 bits.

ยงExample
let pi = Decimal::from_i128_with_scale(3141i128, 3);
assert_eq!(pi.to_string(), "3.141");
Source

pub const fn try_from_i128_with_scale( num: i128, scale: u32, ) -> Result<Decimal, Error>

Checked version of Decimal::from_i128_with_scale. Will return Err instead of panicking at run-time.

ยงExample
let max = Decimal::try_from_i128_with_scale(i128::MAX, u32::MAX);
assert!(max.is_err());
Source

pub const fn from_parts( lo: u32, mid: u32, hi: u32, negative: bool, scale: u32, ) -> Decimal

Returns a Decimal using the instances constituent parts.

ยงArguments
  • lo - The low 32 bits of a 96-bit integer.
  • mid - The middle 32 bits of a 96-bit integer.
  • hi - The high 32 bits of a 96-bit integer.
  • negative - true to indicate a negative number.
  • scale - A power of 10 ranging from 0 to Self::MAX_SCALE.
ยงExample
let pi = Decimal::from_parts(1102470952, 185874565, 1703060790, false, 28);
assert_eq!(pi.to_string(), "3.1415926535897932384626433832");
Source

pub fn from_scientific(value: &str) -> Result<Decimal, Error>

Returns a Result which if successful contains the Decimal constitution of the scientific notation provided by value.

ยงArguments
  • value - The scientific notation of the Decimal.
ยงExample
let value = Decimal::from_scientific("9.7e-7")?;
assert_eq!(value.to_string(), "0.00000097");
Source

pub fn from_str_radix(str: &str, radix: u32) -> Result<Decimal, Error>

Converts a string slice in a given base to a decimal.

The string is expected to be an optional + sign followed by digits. Digits are a subset of these characters, depending on radix, and will return an error if outside the expected range:

  • 0-9
  • a-z
  • A-Z
ยงExamples

Basic usage:

assert_eq!(Decimal::from_str_radix("A", 16)?.to_string(), "10");
Source

pub fn from_str_exact(str: &str) -> Result<Decimal, Error>

Parses a string slice into a decimal. If the value underflows and cannot be represented with the given scale then this will return an error.

ยงExamples

Basic usage:

assert_eq!(Decimal::from_str_exact("0.001")?.to_string(), "0.001");
assert_eq!(Decimal::from_str_exact("0.00000_00000_00000_00000_00000_001")?.to_string(), "0.0000000000000000000000000001");
assert_eq!(Decimal::from_str_exact("0.00000_00000_00000_00000_00000_0001"), Err(Error::Underflow));
Source

pub const fn scale(&self) -> u32

Returns the scale of the decimal number, otherwise known as e.

ยงExample
let num = Decimal::new(1234, 3);
assert_eq!(num.scale(), 3u32);
Source

pub const fn mantissa(&self) -> i128

Returns the mantissa of the decimal number.

ยงExample

let num = dec!(-1.2345678);
assert_eq!(num.mantissa(), -12345678i128);
assert_eq!(num.scale(), 7);
Source

pub const fn is_zero(&self) -> bool

Returns true if this Decimal number is equivalent to zero.

ยงExample
let num = Decimal::ZERO;
assert!(num.is_zero());
Source

pub fn is_integer(&self) -> bool

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

ยงExample
assert_eq!(dec!(5).is_integer(), true);
// Trailing zeros are also ignored
assert_eq!(dec!(5.0000).is_integer(), true);
// If there is a fractional part then it is not an integer
assert_eq!(dec!(5.1).is_integer(), false);
Source

pub fn set_sign(&mut self, positive: bool)

๐Ÿ‘ŽDeprecated since 1.4.0: please use set_sign_positive instead

An optimized method for changing the sign of a decimal number.

ยงArguments
  • positive: true if the resulting decimal should be positive.
ยงExample
let mut one = Decimal::ONE;
one.set_sign(false);
assert_eq!(one.to_string(), "-1");
Source

pub fn set_sign_positive(&mut self, positive: bool)

An optimized method for changing the sign of a decimal number.

ยงArguments
  • positive: true if the resulting decimal should be positive.
ยงExample
let mut one = Decimal::ONE;
one.set_sign_positive(false);
assert_eq!(one.to_string(), "-1");
Source

pub fn set_sign_negative(&mut self, negative: bool)

An optimized method for changing the sign of a decimal number.

ยงArguments
  • negative: true if the resulting decimal should be negative.
ยงExample
let mut one = Decimal::ONE;
one.set_sign_negative(true);
assert_eq!(one.to_string(), "-1");
Source

pub fn set_scale(&mut self, scale: u32) -> Result<(), Error>

An optimized method for changing the scale of a decimal number.

ยงArguments
  • scale: the new scale of the number
ยงExample
let mut one = Decimal::ONE;
one.set_scale(5)?;
assert_eq!(one.to_string(), "0.00001");
Source

pub fn rescale(&mut self, scale: u32)

Modifies the Decimal towards the desired scale, attempting to do so without changing the underlying number itself.

Setting the scale to something less then the current Decimals scale will cause the newly created Decimal to perform rounding using the MidpointAwayFromZero strategy.

Scales greater than the maximum precision that can be represented by Decimal will be automatically rounded to either Self::MAX_SCALE or the maximum precision that can be represented with the given mantissa.

ยงArguments
  • scale: The desired scale to use for the new Decimal number.
ยงExample

// Rescaling to a higher scale preserves the value
let mut number = dec!(1.123);
assert_eq!(number.scale(), 3);
number.rescale(6);
assert_eq!(number.to_string(), "1.123000");
assert_eq!(number.scale(), 6);

// Rescaling to a lower scale forces the number to be rounded
let mut number = dec!(1.45);
assert_eq!(number.scale(), 2);
number.rescale(1);
assert_eq!(number.to_string(), "1.5");
assert_eq!(number.scale(), 1);

// This function never fails. Consequently, if a scale is provided that is unable to be
// represented using the given mantissa, then the maximum possible scale is used.
let mut number = dec!(11.76470588235294);
assert_eq!(number.scale(), 14);
number.rescale(28);
// A scale of 28 cannot be represented given this mantissa, however it was able to represent
// a number with a scale of 27
assert_eq!(number.to_string(), "11.764705882352940000000000000");
assert_eq!(number.scale(), 27);
Source

pub const fn serialize(&self) -> [u8; 16]

Returns a serialized version of the decimal number. The resulting byte array will have the following representation:

  • Bytes 1-4: flags
  • Bytes 5-8: lo portion of m
  • Bytes 9-12: mid portion of m
  • Bytes 13-16: high portion of m
Source

pub fn deserialize(bytes: [u8; 16]) -> Decimal

Deserializes the given bytes into a decimal number. The deserialized byte representation must be 16 bytes and adhere to the following convention:

  • Bytes 1-4: flags
  • Bytes 5-8: lo portion of m
  • Bytes 9-12: mid portion of m
  • Bytes 13-16: high portion of m
Source

pub fn is_negative(&self) -> bool

๐Ÿ‘ŽDeprecated since 0.6.3: please use is_sign_negative instead

Returns true if the decimal is negative.

Source

pub fn is_positive(&self) -> bool

๐Ÿ‘ŽDeprecated since 0.6.3: please use is_sign_positive instead

Returns true if the decimal is positive.

Source

pub const fn is_sign_negative(&self) -> bool

Returns true if the sign bit of the decimal is negative.

ยงExample
assert_eq!(true, Decimal::new(-1, 0).is_sign_negative());
assert_eq!(false, Decimal::new(1, 0).is_sign_negative());
Source

pub const fn is_sign_positive(&self) -> bool

Returns true if the sign bit of the decimal is positive.

ยงExample
assert_eq!(false, Decimal::new(-1, 0).is_sign_positive());
assert_eq!(true, Decimal::new(1, 0).is_sign_positive());
Source

pub const fn min_value() -> Decimal

๐Ÿ‘ŽDeprecated since 1.12.0: Use the associated constant Decimal::MIN

Returns the minimum possible number that Decimal can represent.

Source

pub const fn max_value() -> Decimal

๐Ÿ‘ŽDeprecated since 1.12.0: Use the associated constant Decimal::MAX

Returns the maximum possible number that Decimal can represent.

Source

pub fn trunc(&self) -> Decimal

Returns a new Decimal integral with no fractional portion. This is a true truncation whereby no rounding is performed.

ยงExample
let pi = dec!(3.141);
assert_eq!(pi.trunc(), dec!(3));

// Negative numbers are similarly truncated without rounding
let neg = dec!(-1.98765);
assert_eq!(neg.trunc(), Decimal::NEGATIVE_ONE);
Source

pub fn trunc_with_scale(&self, scale: u32) -> Decimal

Returns a new Decimal with the fractional portion delimited by scale. This is a true truncation whereby no rounding is performed.

ยงExample
let pi = dec!(3.141592);
assert_eq!(pi.trunc_with_scale(2), dec!(3.14));

// Negative numbers are similarly truncated without rounding
let neg = dec!(-1.98765);
assert_eq!(neg.trunc_with_scale(1), dec!(-1.9));
Source

pub fn fract(&self) -> Decimal

Returns a new Decimal representing the fractional portion of the number.

ยงExample
let pi = Decimal::new(3141, 3);
let fract = Decimal::new(141, 3);
// note that it returns a decimal
assert_eq!(pi.fract(), fract);
Source

pub fn abs(&self) -> Decimal

Computes the absolute value of self.

ยงExample
let num = Decimal::new(-3141, 3);
assert_eq!(num.abs().to_string(), "3.141");
Source

pub fn floor(&self) -> Decimal

Returns the largest integer less than or equal to a number.

ยงExample
let num = Decimal::new(3641, 3);
assert_eq!(num.floor().to_string(), "3");
Source

pub fn ceil(&self) -> Decimal

Returns the smallest integer greater than or equal to a number.

ยงExample
let num = Decimal::new(3141, 3);
assert_eq!(num.ceil().to_string(), "4");
let num = Decimal::new(3, 0);
assert_eq!(num.ceil().to_string(), "3");
Source

pub fn max(self, other: Decimal) -> Decimal

Returns the maximum of the two numbers.

let x = Decimal::new(1, 0);
let y = Decimal::new(2, 0);
assert_eq!(y, x.max(y));
Source

pub fn min(self, other: Decimal) -> Decimal

Returns the minimum of the two numbers.

let x = Decimal::new(1, 0);
let y = Decimal::new(2, 0);
assert_eq!(x, x.min(y));
Source

pub fn normalize(&self) -> Decimal

Strips any trailing zeroโ€™s from a Decimal and converts -0 to 0.

ยงExample
let number = Decimal::from_str("3.100")?;
assert_eq!(number.normalize().to_string(), "3.1");
Source

pub fn normalize_assign(&mut self)

An in place version of normalize. Strips any trailing zeroโ€™s from a Decimal and converts -0 to 0.

ยงExample
let mut number = Decimal::from_str("3.100")?;
assert_eq!(number.to_string(), "3.100");
number.normalize_assign();
assert_eq!(number.to_string(), "3.1");
Source

pub fn round(&self) -> Decimal

Returns a new Decimal number with no fractional portion (i.e. an integer). Rounding currently follows โ€œBankers Roundingโ€ rules. e.g. 6.5 -> 6, 7.5 -> 8

ยงExample
// Demonstrating bankers rounding...
let number_down = Decimal::new(65, 1);
let number_up   = Decimal::new(75, 1);
assert_eq!(number_down.round().to_string(), "6");
assert_eq!(number_up.round().to_string(), "8");
Source

pub fn round_dp_with_strategy( &self, dp: u32, strategy: RoundingStrategy, ) -> Decimal

Returns a new Decimal number with the specified number of decimal points for fractional portion. Rounding is performed using the provided RoundingStrategy

ยงArguments
  • dp: the number of decimal points to round to.
  • strategy: the RoundingStrategy to use.
ยงExample
let tax = dec!(3.4395);
assert_eq!(tax.round_dp_with_strategy(2, RoundingStrategy::MidpointAwayFromZero).to_string(), "3.44");
Source

pub fn round_dp(&self, dp: u32) -> Decimal

Returns a new Decimal number with the specified number of decimal points for fractional portion. Rounding currently follows โ€œBankers Roundingโ€ rules. e.g. 6.5 -> 6, 7.5 -> 8

ยงArguments
  • dp: the number of decimal points to round to.
ยงExample
let pi = dec!(3.1415926535897932384626433832);
assert_eq!(pi.round_dp(2).to_string(), "3.14");
Source

pub fn round_sf(&self, digits: u32) -> Option<Decimal>

Returns Some(Decimal) number rounded to the specified number of significant digits. If the resulting number is unable to be represented by the Decimal number then None will be returned. When the number of significant figures of the Decimal being rounded is greater than the requested number of significant digits then rounding will be performed using MidpointNearestEven strategy.

ยงArguments
  • digits: the number of significant digits to round to.
ยงRemarks

A significant figure is determined using the following rules:

  1. Non-zero digits are always significant.
  2. Zeros between non-zero digits are always significant.
  3. Leading zeros are never significant.
  4. Trailing zeros are only significant if the number contains a decimal point.
ยงExample

let value = dec!(305.459);
assert_eq!(value.round_sf(0), Some(dec!(0)));
assert_eq!(value.round_sf(1), Some(dec!(300)));
assert_eq!(value.round_sf(2), Some(dec!(310)));
assert_eq!(value.round_sf(3), Some(dec!(305)));
assert_eq!(value.round_sf(4), Some(dec!(305.5)));
assert_eq!(value.round_sf(5), Some(dec!(305.46)));
assert_eq!(value.round_sf(6), Some(dec!(305.459)));
assert_eq!(value.round_sf(7), Some(dec!(305.4590)));
assert_eq!(Decimal::MAX.round_sf(1), None);

let value = dec!(0.012301);
assert_eq!(value.round_sf(3), Some(dec!(0.0123)));
Source

pub fn round_sf_with_strategy( &self, digits: u32, strategy: RoundingStrategy, ) -> Option<Decimal>

Returns Some(Decimal) number rounded to the specified number of significant digits. If the resulting number is unable to be represented by the Decimal number then None will be returned. When the number of significant figures of the Decimal being rounded is greater than the requested number of significant digits then rounding will be performed using the provided RoundingStrategy.

ยงArguments
  • digits: the number of significant digits to round to.
  • strategy: if required, the rounding strategy to use.
ยงRemarks

A significant figure is determined using the following rules:

  1. Non-zero digits are always significant.
  2. Zeros between non-zero digits are always significant.
  3. Leading zeros are never significant.
  4. Trailing zeros are only significant if the number contains a decimal point.
ยงExample

let value = dec!(305.459);
assert_eq!(value.round_sf_with_strategy(0, RoundingStrategy::ToZero), Some(dec!(0)));
assert_eq!(value.round_sf_with_strategy(1, RoundingStrategy::ToZero), Some(dec!(300)));
assert_eq!(value.round_sf_with_strategy(2, RoundingStrategy::ToZero), Some(dec!(300)));
assert_eq!(value.round_sf_with_strategy(3, RoundingStrategy::ToZero), Some(dec!(305)));
assert_eq!(value.round_sf_with_strategy(4, RoundingStrategy::ToZero), Some(dec!(305.4)));
assert_eq!(value.round_sf_with_strategy(5, RoundingStrategy::ToZero), Some(dec!(305.45)));
assert_eq!(value.round_sf_with_strategy(6, RoundingStrategy::ToZero), Some(dec!(305.459)));
assert_eq!(value.round_sf_with_strategy(7, RoundingStrategy::ToZero), Some(dec!(305.4590)));
assert_eq!(Decimal::MAX.round_sf_with_strategy(1, RoundingStrategy::ToZero), Some(dec!(70000000000000000000000000000)));

let value = dec!(0.012301);
assert_eq!(value.round_sf_with_strategy(3, RoundingStrategy::AwayFromZero), Some(dec!(0.0124)));
Source

pub const fn unpack(&self) -> UnpackedDecimal

Convert Decimal to an internal representation of the underlying struct. This is useful for debugging the internal state of the object.

ยงImportant Disclaimer

This is primarily intended for library maintainers. The internal representation of a Decimal is considered โ€œunstableโ€ for public use.

ยงExample

let pi = dec!(3.1415926535897932384626433832);
assert_eq!(format!("{:?}", pi), "3.1415926535897932384626433832");
assert_eq!(format!("{:?}", pi.unpack()), "UnpackedDecimal { \
    negative: false, scale: 28, hi: 1703060790, mid: 185874565, lo: 1102470952 \
}");
Source

pub fn from_f32_retain(n: f32) -> Option<Decimal>

Parses a 32-bit float into a Decimal number whilst retaining any non-guaranteed precision.

Typically when a float is parsed in Rust Decimal, any excess bits (after ~7.22 decimal points for f32 as per IEEE-754) are removed due to any digits following this are considered an approximation at best. This function bypasses this additional step and retains these excess bits.

ยงExample
// Usually floats are parsed leveraging float guarantees. i.e. 0.1_f32 => 0.1
assert_eq!("0.1", Decimal::from_f32(0.1_f32).unwrap().to_string());

// Sometimes, we may want to represent the approximation exactly.
assert_eq!("0.100000001490116119384765625", Decimal::from_f32_retain(0.1_f32).unwrap().to_string());
Source

pub fn from_f64_retain(n: f64) -> Option<Decimal>

Parses a 64-bit float into a Decimal number whilst retaining any non-guaranteed precision.

Typically when a float is parsed in Rust Decimal, any excess bits (after ~15.95 decimal points for f64 as per IEEE-754) are removed due to any digits following this are considered an approximation at best. This function bypasses this additional step and retains these excess bits.

ยงExample
// Usually floats are parsed leveraging float guarantees. i.e. 0.1_f64 => 0.1
assert_eq!("0.1", Decimal::from_f64(0.1_f64).unwrap().to_string());

// Sometimes, we may want to represent the approximation exactly.
assert_eq!("0.1000000000000000055511151231", Decimal::from_f64_retain(0.1_f64).unwrap().to_string());
Sourceยง

impl Decimal

Source

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

Checked addition. Computes self + other, returning None if overflow occurred.

Source

pub fn saturating_add(self, other: Decimal) -> Decimal

Saturating addition. Computes self + other, saturating at the relevant upper or lower boundary.

Source

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

Checked multiplication. Computes self * other, returning None if overflow occurred.

Source

pub fn saturating_mul(self, other: Decimal) -> Decimal

Saturating multiplication. Computes self * other, saturating at the relevant upper or lower boundary.

Source

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

Checked subtraction. Computes self - other, returning None if overflow occurred.

Source

pub fn saturating_sub(self, other: Decimal) -> Decimal

Saturating subtraction. Computes self - other, saturating at the relevant upper or lower boundary.

Source

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

Checked division. Computes self / other, returning None if overflow occurred.

Source

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

Checked remainder. Computes self % other, returning None if overflow occurred.

Trait Implementationsยง

Sourceยง

impl Add<&Decimal> for &Decimal

Sourceยง

type Output = Decimal

The resulting type after applying the + operator.
Sourceยง

fn add(self, other: &Decimal) -> Decimal

Performs the + operation. Read more
Sourceยง

impl<'a> Add<&'a Decimal> for Decimal

Sourceยง

type Output = Decimal

The resulting type after applying the + operator.
Sourceยง

fn add(self, other: &Decimal) -> Decimal

Performs the + operation. Read more
Sourceยง

impl<'a> Add<Decimal> for &'a Decimal

Sourceยง

type Output = Decimal

The resulting type after applying the + operator.
Sourceยง

fn add(self, other: Decimal) -> Decimal

Performs the + operation. Read more
Sourceยง

impl Add for Decimal

Sourceยง

type Output = Decimal

The resulting type after applying the + operator.
Sourceยง

fn add(self, other: Decimal) -> Decimal

Performs the + operation. Read more
Sourceยง

impl<'a> AddAssign<&'a Decimal> for &'a mut Decimal

Sourceยง

fn add_assign(&mut self, other: &'a Decimal)

Performs the += operation. Read more
Sourceยง

impl<'a> AddAssign<&'a Decimal> for Decimal

Sourceยง

fn add_assign(&mut self, other: &'a Decimal)

Performs the += operation. Read more
Sourceยง

impl AddAssign<Decimal> for &mut Decimal

Sourceยง

fn add_assign(&mut self, other: Decimal)

Performs the += operation. Read more
Sourceยง

impl AddAssign for Decimal

Sourceยง

fn add_assign(&mut self, other: Decimal)

Performs the += operation. Read more
Sourceยง

impl CheckedAdd for Decimal

Sourceยง

fn checked_add(&self, v: &Decimal) -> Option<Decimal>

Adds two numbers, checking for overflow. If overflow happens, None is returned.
Sourceยง

impl CheckedDiv for Decimal

Sourceยง

fn checked_div(&self, v: &Decimal) -> Option<Decimal>

Divides two numbers, checking for underflow, overflow and division by zero. If any of that happens, None is returned.
Sourceยง

impl CheckedMul for Decimal

Sourceยง

fn checked_mul(&self, v: &Decimal) -> Option<Decimal>

Multiplies two numbers, checking for underflow or overflow. If underflow or overflow happens, None is returned.
Sourceยง

impl CheckedRem for Decimal

Sourceยง

fn checked_rem(&self, v: &Decimal) -> Option<Decimal>

Finds the remainder of dividing two numbers, checking for underflow, overflow and division by zero. If any of that happens, None is returned. Read more
Sourceยง

impl CheckedSub for Decimal

Sourceยง

fn checked_sub(&self, v: &Decimal) -> Option<Decimal>

Subtracts two numbers, checking for underflow. If underflow happens, None is returned.
Sourceยง

impl Clone for Decimal

Sourceยง

fn clone(&self) -> Decimal

Returns a duplicate of the value. Read more
1.0.0 ยท 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<(), Error>

Formats the value using the given formatter. Read more
Sourceยง

impl Decode<'_, Mssql> for Decimal

Sourceยง

fn decode( value: MssqlValueRef<'_>, ) -> Result<Decimal, Box<dyn Error + Send + Sync>>

Decode a new value of this type using a raw value from the database.
Sourceยง

impl Decode<'_, MySql> for Decimal

Sourceยง

fn decode( value: MySqlValueRef<'_>, ) -> Result<Decimal, Box<dyn Error + Send + Sync>>

Decode a new value of this type using a raw value from the database.
Sourceยง

impl Decode<'_, Postgres> for Decimal

Sourceยง

fn decode( value: PgValueRef<'_>, ) -> Result<Decimal, Box<dyn Error + Send + Sync>>

Decode a new value of this type using a raw value from the database.
Sourceยง

impl Decode<'_, Sqlite> for Decimal

Sourceยง

fn decode( value: SqliteValueRef<'_>, ) -> Result<Decimal, Box<dyn Error + Send + Sync>>

Decode a new value of this type using a raw value from the database.
Sourceยง

impl<'r> Decode<'r, Any> for Decimal
where Decimal: AnyDecode<'r>,

Sourceยง

fn decode( value: AnyValueRef<'r>, ) -> Result<Decimal, Box<dyn Error + Send + Sync>>

Decode a new value of this type using a raw value from the database.
Sourceยง

impl Default for Decimal

Sourceยง

fn default() -> Decimal

Returns the default value for a Decimal (equivalent to Decimal::ZERO). Read more

Sourceยง

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

Sourceยง

fn deserialize<D>( deserializer: D, ) -> Result<Decimal, <D as Deserializer<'de>>::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<(), Error>

Formats the value using the given formatter. Read more
Sourceยง

impl Div<&Decimal> for &Decimal

Sourceยง

type Output = Decimal

The resulting type after applying the / operator.
Sourceยง

fn div(self, other: &Decimal) -> Decimal

Performs the / operation. Read more
Sourceยง

impl<'a> Div<&'a Decimal> for Decimal

Sourceยง

type Output = Decimal

The resulting type after applying the / operator.
Sourceยง

fn div(self, other: &Decimal) -> Decimal

Performs the / operation. Read more
Sourceยง

impl<'a> Div<Decimal> for &'a Decimal

Sourceยง

type Output = Decimal

The resulting type after applying the / operator.
Sourceยง

fn div(self, other: Decimal) -> Decimal

Performs the / operation. Read more
Sourceยง

impl Div for Decimal

Sourceยง

type Output = Decimal

The resulting type after applying the / operator.
Sourceยง

fn div(self, other: Decimal) -> Decimal

Performs the / operation. Read more
Sourceยง

impl<'a> DivAssign<&'a Decimal> for &'a mut Decimal

Sourceยง

fn div_assign(&mut self, other: &'a Decimal)

Performs the /= operation. Read more
Sourceยง

impl<'a> DivAssign<&'a Decimal> for Decimal

Sourceยง

fn div_assign(&mut self, other: &'a Decimal)

Performs the /= operation. Read more
Sourceยง

impl DivAssign<Decimal> for &mut Decimal

Sourceยง

fn div_assign(&mut self, other: Decimal)

Performs the /= operation. Read more
Sourceยง

impl DivAssign for Decimal

Sourceยง

fn div_assign(&mut self, other: Decimal)

Performs the /= operation. Read more
Sourceยง

impl Encode<'_, Mssql> for Decimal

Sourceยง

fn produces(&self) -> Option<MssqlTypeInfo>

Sourceยง

fn encode_by_ref(&self, buf: &mut Vec<u8>) -> IsNull

Writes the value of self into buf without moving self. Read more
Sourceยง

fn encode(self, buf: &mut <DB as HasArguments<'q>>::ArgumentBuffer) -> IsNull
where Self: Sized,

Writes the value of self into buf in the expected format for the database.
Sourceยง

fn size_hint(&self) -> usize

Sourceยง

impl Encode<'_, MySql> for Decimal

Sourceยง

fn encode_by_ref(&self, buf: &mut Vec<u8>) -> IsNull

Writes the value of self into buf without moving self. Read more
Sourceยง

fn encode(self, buf: &mut <DB as HasArguments<'q>>::ArgumentBuffer) -> IsNull
where Self: Sized,

Writes the value of self into buf in the expected format for the database.
Sourceยง

fn produces(&self) -> Option<<DB as Database>::TypeInfo>

Sourceยง

fn size_hint(&self) -> usize

Sourceยง

impl Encode<'_, Postgres> for Decimal

ยงPanics

If this Decimal cannot be represented by PgNumeric.

Sourceยง

fn encode_by_ref(&self, buf: &mut PgArgumentBuffer) -> IsNull

Writes the value of self into buf without moving self. Read more
Sourceยง

fn encode(self, buf: &mut <DB as HasArguments<'q>>::ArgumentBuffer) -> IsNull
where Self: Sized,

Writes the value of self into buf in the expected format for the database.
Sourceยง

fn produces(&self) -> Option<<DB as Database>::TypeInfo>

Sourceยง

fn size_hint(&self) -> usize

Sourceยง

impl Encode<'_, Sqlite> for Decimal

Sourceยง

fn encode_by_ref(&self, buf: &mut Vec<SqliteArgumentValue<'_>>) -> IsNull

Writes the value of self into buf without moving self. Read more
Sourceยง

fn encode(self, buf: &mut <DB as HasArguments<'q>>::ArgumentBuffer) -> IsNull
where Self: Sized,

Writes the value of self into buf in the expected format for the database.
Sourceยง

fn produces(&self) -> Option<<DB as Database>::TypeInfo>

Sourceยง

fn size_hint(&self) -> usize

Sourceยง

impl<'q> Encode<'q, Any> for Decimal
where Decimal: AnyEncode<'q>,

Sourceยง

fn encode_by_ref(&self, buf: &mut AnyArgumentBuffer<'q>) -> IsNull

Writes the value of self into buf without moving self. Read more
Sourceยง

fn encode(self, buf: &mut <DB as HasArguments<'q>>::ArgumentBuffer) -> IsNull
where Self: Sized,

Writes the value of self into buf in the expected format for the database.
Sourceยง

fn produces(&self) -> Option<<DB as Database>::TypeInfo>

Sourceยง

fn size_hint(&self) -> usize

Sourceยง

impl From<i128> for Decimal

Conversion to Decimal.

Sourceยง

fn from(t: i128) -> Decimal

Converts to this type from the input type.
Sourceยง

impl From<i16> for Decimal

Conversion to Decimal.

Sourceยง

fn from(t: i16) -> Decimal

Converts to this type from the input type.
Sourceยง

impl From<i32> for Decimal

Conversion to Decimal.

Sourceยง

fn from(t: i32) -> Decimal

Converts to this type from the input type.
Sourceยง

impl From<i64> for Decimal

Conversion to Decimal.

Sourceยง

fn from(t: i64) -> Decimal

Converts to this type from the input type.
Sourceยง

impl From<i8> for Decimal

Conversion to Decimal.

Sourceยง

fn from(t: i8) -> Decimal

Converts to this type from the input type.
Sourceยง

impl From<isize> for Decimal

Conversion to Decimal.

Sourceยง

fn from(t: isize) -> Decimal

Converts to this type from the input type.
Sourceยง

impl From<u128> for Decimal

Conversion to Decimal.

Sourceยง

fn from(t: u128) -> Decimal

Converts to this type from the input type.
Sourceยง

impl From<u16> for Decimal

Conversion to Decimal.

Sourceยง

fn from(t: u16) -> Decimal

Converts to this type from the input type.
Sourceยง

impl From<u32> for Decimal

Conversion to Decimal.

Sourceยง

fn from(t: u32) -> Decimal

Converts to this type from the input type.
Sourceยง

impl From<u64> for Decimal

Conversion to Decimal.

Sourceยง

fn from(t: u64) -> Decimal

Converts to this type from the input type.
Sourceยง

impl From<u8> for Decimal

Conversion to Decimal.

Sourceยง

fn from(t: u8) -> Decimal

Converts to this type from the input type.
Sourceยง

impl From<usize> for Decimal

Conversion to Decimal.

Sourceยง

fn from(t: usize) -> Decimal

Converts to this type from the input type.
Sourceยง

impl FromPrimitive for Decimal

Sourceยง

fn from_i32(n: i32) -> Option<Decimal>

Converts an i32 to return an optional value of this type. If the value cannot be represented by this type, then None is returned.
Sourceยง

fn from_i64(n: i64) -> Option<Decimal>

Converts an i64 to return an optional value of this type. If the value cannot be represented by this type, then None is returned.
Sourceยง

fn from_i128(n: i128) -> Option<Decimal>

Converts an i128 to return an optional value of this type. If the value cannot be represented by this type, then None is returned. Read more
Sourceยง

fn from_u32(n: u32) -> Option<Decimal>

Converts an u32 to return an optional value of this type. If the value cannot be represented by this type, then None is returned.
Sourceยง

fn from_u64(n: u64) -> Option<Decimal>

Converts an u64 to return an optional value of this type. If the value cannot be represented by this type, then None is returned.
Sourceยง

fn from_u128(n: u128) -> Option<Decimal>

Converts an u128 to return an optional value of this type. If the value cannot be represented by this type, then None is returned. Read more
Sourceยง

fn from_f32(n: f32) -> Option<Decimal>

Converts a f32 to return an optional value of this type. If the value cannot be represented by this type, then None is returned.
Sourceยง

fn from_f64(n: f64) -> Option<Decimal>

Converts a f64 to return an optional value of this type. If the value cannot be represented by this type, then None is returned. Read more
Sourceยง

fn from_isize(n: isize) -> Option<Self>

Converts an isize to return an optional value of this type. If the value cannot be represented by this type, then None is returned.
Sourceยง

fn from_i8(n: i8) -> Option<Self>

Converts an i8 to return an optional value of this type. If the value cannot be represented by this type, then None is returned.
Sourceยง

fn from_i16(n: i16) -> Option<Self>

Converts an i16 to return an optional value of this type. If the value cannot be represented by this type, then None is returned.
Sourceยง

fn from_usize(n: usize) -> Option<Self>

Converts a usize to return an optional value of this type. If the value cannot be represented by this type, then None is returned.
Sourceยง

fn from_u8(n: u8) -> Option<Self>

Converts an u8 to return an optional value of this type. If the value cannot be represented by this type, then None is returned.
Sourceยง

fn from_u16(n: u16) -> Option<Self>

Converts an u16 to return an optional value of this type. If the value cannot be represented by this type, then None is returned.
Sourceยง

impl FromStr for Decimal

Sourceยง

type Err = Error

The associated error which can be returned from parsing.
Sourceยง

fn from_str(value: &str) -> Result<Decimal, <Decimal as FromStr>::Err>

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

impl Hash for Decimal

Sourceยง

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

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

Sourceยง

type Output = Decimal

The result after applying the operator.
Sourceยง

fn inv(self) -> Decimal

Returns the multiplicative inverse of self. Read more
Sourceยง

impl LowerExp for Decimal

Sourceยง

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

Formats the value using the given formatter. Read more
Sourceยง

impl Mul<&Decimal> for &Decimal

Sourceยง

type Output = Decimal

The resulting type after applying the * operator.
Sourceยง

fn mul(self, other: &Decimal) -> Decimal

Performs the * operation. Read more
Sourceยง

impl<'a> Mul<&'a Decimal> for Decimal

Sourceยง

type Output = Decimal

The resulting type after applying the * operator.
Sourceยง

fn mul(self, other: &Decimal) -> Decimal

Performs the * operation. Read more
Sourceยง

impl<'a> Mul<Decimal> for &'a Decimal

Sourceยง

type Output = Decimal

The resulting type after applying the * operator.
Sourceยง

fn mul(self, other: Decimal) -> Decimal

Performs the * operation. Read more
Sourceยง

impl Mul for Decimal

Sourceยง

type Output = Decimal

The resulting type after applying the * operator.
Sourceยง

fn mul(self, other: Decimal) -> Decimal

Performs the * operation. Read more
Sourceยง

impl<'a> MulAssign<&'a Decimal> for &'a mut Decimal

Sourceยง

fn mul_assign(&mut self, other: &'a Decimal)

Performs the *= operation. Read more
Sourceยง

impl<'a> MulAssign<&'a Decimal> for Decimal

Sourceยง

fn mul_assign(&mut self, other: &'a Decimal)

Performs the *= operation. Read more
Sourceยง

impl MulAssign<Decimal> for &mut Decimal

Sourceยง

fn mul_assign(&mut self, other: Decimal)

Performs the *= operation. Read more
Sourceยง

impl MulAssign for Decimal

Sourceยง

fn mul_assign(&mut self, other: Decimal)

Performs the *= operation. Read more
Sourceยง

impl Neg for &Decimal

Sourceยง

type Output = Decimal

The resulting type after applying the - operator.
Sourceยง

fn neg(self) -> Decimal

Performs the unary - operation. Read more
Sourceยง

impl Neg for Decimal

Sourceยง

type Output = Decimal

The resulting type after applying the - operator.
Sourceยง

fn neg(self) -> Decimal

Performs the unary - operation. Read more
Sourceยง

impl Num for Decimal

Sourceยง

type FromStrRadixErr = Error

Sourceยง

fn from_str_radix( str: &str, radix: u32, ) -> Result<Decimal, <Decimal as Num>::FromStrRadixErr>

Convert from a string and radix (typically 2..=36). Read more
Sourceยง

impl One for Decimal

Sourceยง

fn one() -> Decimal

Returns the multiplicative identity element of Self, 1. Read more
Sourceยง

fn set_one(&mut self)

Sets self to the multiplicative identity element of Self, 1.
Sourceยง

fn is_one(&self) -> bool
where Self: PartialEq,

Returns true if self is equal to the multiplicative identity. Read more
Sourceยง

impl Ord for Decimal

Sourceยง

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

This method returns an Ordering between self and other. Read more
1.21.0 ยท Sourceยง

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

Compares and returns the maximum of two values. Read more
1.21.0 ยท Sourceยง

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

Compares and returns the minimum of two values. Read more
1.50.0 ยท Sourceยง

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: &Decimal) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 ยท Sourceยง

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: &Decimal) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 ยท 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 ยท 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 ยท 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 ยท 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 PgHasArrayType for Decimal

Sourceยง

impl<'a> Product<&'a Decimal> for Decimal

Sourceยง

fn product<I>(iter: I) -> Decimal
where I: Iterator<Item = &'a Decimal>,

Panics if out-of-bounds

Sourceยง

impl Product for Decimal

Sourceยง

fn product<I>(iter: I) -> Decimal
where I: Iterator<Item = Decimal>,

Panics if out-of-bounds

Sourceยง

impl Rem<&Decimal> for &Decimal

Sourceยง

type Output = Decimal

The resulting type after applying the % operator.
Sourceยง

fn rem(self, other: &Decimal) -> Decimal

Performs the % operation. Read more
Sourceยง

impl<'a> Rem<&'a Decimal> for Decimal

Sourceยง

type Output = Decimal

The resulting type after applying the % operator.
Sourceยง

fn rem(self, other: &Decimal) -> Decimal

Performs the % operation. Read more
Sourceยง

impl<'a> Rem<Decimal> for &'a Decimal

Sourceยง

type Output = Decimal

The resulting type after applying the % operator.
Sourceยง

fn rem(self, other: Decimal) -> Decimal

Performs the % operation. Read more
Sourceยง

impl Rem for Decimal

Sourceยง

type Output = Decimal

The resulting type after applying the % operator.
Sourceยง

fn rem(self, other: Decimal) -> Decimal

Performs the % operation. Read more
Sourceยง

impl<'a> RemAssign<&'a Decimal> for &'a mut Decimal

Sourceยง

fn rem_assign(&mut self, other: &'a Decimal)

Performs the %= operation. Read more
Sourceยง

impl<'a> RemAssign<&'a Decimal> for Decimal

Sourceยง

fn rem_assign(&mut self, other: &'a Decimal)

Performs the %= operation. Read more
Sourceยง

impl RemAssign<Decimal> for &mut Decimal

Sourceยง

fn rem_assign(&mut self, other: Decimal)

Performs the %= operation. Read more
Sourceยง

impl RemAssign for Decimal

Sourceยง

fn rem_assign(&mut self, other: Decimal)

Performs the %= operation. Read more
Sourceยง

impl Serialize for Decimal

Sourceยง

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

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

impl Signed for Decimal

Sourceยง

fn abs(&self) -> Decimal

Computes the absolute value. Read more
Sourceยง

fn abs_sub(&self, other: &Decimal) -> Decimal

The positive difference of two numbers. Read more
Sourceยง

fn signum(&self) -> Decimal

Returns the sign of the number. Read more
Sourceยง

fn is_positive(&self) -> bool

Returns true if the number is positive and false if the number is zero or negative.
Sourceยง

fn is_negative(&self) -> bool

Returns true if the number is negative and false if the number is zero or positive.
Sourceยง

impl Sub<&Decimal> for &Decimal

Sourceยง

type Output = Decimal

The resulting type after applying the - operator.
Sourceยง

fn sub(self, other: &Decimal) -> Decimal

Performs the - operation. Read more
Sourceยง

impl<'a> Sub<&'a Decimal> for Decimal

Sourceยง

type Output = Decimal

The resulting type after applying the - operator.
Sourceยง

fn sub(self, other: &Decimal) -> Decimal

Performs the - operation. Read more
Sourceยง

impl<'a> Sub<Decimal> for &'a Decimal

Sourceยง

type Output = Decimal

The resulting type after applying the - operator.
Sourceยง

fn sub(self, other: Decimal) -> Decimal

Performs the - operation. Read more
Sourceยง

impl Sub for Decimal

Sourceยง

type Output = Decimal

The resulting type after applying the - operator.
Sourceยง

fn sub(self, other: Decimal) -> Decimal

Performs the - operation. Read more
Sourceยง

impl<'a> SubAssign<&'a Decimal> for &'a mut Decimal

Sourceยง

fn sub_assign(&mut self, other: &'a Decimal)

Performs the -= operation. Read more
Sourceยง

impl<'a> SubAssign<&'a Decimal> for Decimal

Sourceยง

fn sub_assign(&mut self, other: &'a Decimal)

Performs the -= operation. Read more
Sourceยง

impl SubAssign<Decimal> for &mut Decimal

Sourceยง

fn sub_assign(&mut self, other: Decimal)

Performs the -= operation. Read more
Sourceยง

impl SubAssign for Decimal

Sourceยง

fn sub_assign(&mut self, other: Decimal)

Performs the -= operation. Read more
Sourceยง

impl<'a> Sum<&'a Decimal> for Decimal

Sourceยง

fn sum<I>(iter: I) -> Decimal
where I: Iterator<Item = &'a Decimal>,

Takes an iterator and generates Self from the elements by โ€œsumming upโ€ the items.
Sourceยง

impl Sum for Decimal

Sourceยง

fn sum<I>(iter: I) -> Decimal
where I: Iterator<Item = Decimal>,

Takes an iterator and generates Self from the elements by โ€œsumming upโ€ the items.
Sourceยง

impl ToPrimitive for Decimal

Sourceยง

fn to_i64(&self) -> Option<i64>

Converts the value of self to an i64. If the value cannot be represented by an i64, then None is returned.
Sourceยง

fn to_i128(&self) -> Option<i128>

Converts the value of self to an i128. If the value cannot be represented by an i128 (i64 under the default implementation), then None is returned. Read more
Sourceยง

fn to_u64(&self) -> Option<u64>

Converts the value of self to a u64. If the value cannot be represented by a u64, then None is returned.
Sourceยง

fn to_u128(&self) -> Option<u128>

Converts the value of self to a u128. If the value cannot be represented by a u128 (u64 under the default implementation), then None is returned. Read more
Sourceยง

fn to_f64(&self) -> Option<f64>

Converts the value of self to an f64. Overflows may map to positive or negative inifinity, otherwise None is returned if the value cannot be represented by an f64. Read more
Sourceยง

fn to_isize(&self) -> Option<isize>

Converts the value of self to an isize. If the value cannot be represented by an isize, then None is returned.
Sourceยง

fn to_i8(&self) -> Option<i8>

Converts the value of self to an i8. If the value cannot be represented by an i8, then None is returned.
Sourceยง

fn to_i16(&self) -> Option<i16>

Converts the value of self to an i16. If the value cannot be represented by an i16, then None is returned.
Sourceยง

fn to_i32(&self) -> Option<i32>

Converts the value of self to an i32. If the value cannot be represented by an i32, then None is returned.
Sourceยง

fn to_usize(&self) -> Option<usize>

Converts the value of self to a usize. If the value cannot be represented by a usize, then None is returned.
Sourceยง

fn to_u8(&self) -> Option<u8>

Converts the value of self to a u8. If the value cannot be represented by a u8, then None is returned.
Sourceยง

fn to_u16(&self) -> Option<u16>

Converts the value of self to a u16. If the value cannot be represented by a u16, then None is returned.
Sourceยง

fn to_u32(&self) -> Option<u32>

Converts the value of self to a u32. If the value cannot be represented by a u32, then None is returned.
Sourceยง

fn to_f32(&self) -> Option<f32>

Converts the value of self to an f32. Overflows may map to positive or negative inifinity, otherwise None is returned if the value cannot be represented by an f32.
Sourceยง

impl TryFrom<&str> for Decimal

Try to convert a &str into a Decimal.

Can fail if the value is out of range for Decimal.

Sourceยง

type Error = Error

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

fn try_from(t: &str) -> Result<Decimal, Error>

Performs the conversion.
Sourceยง

impl TryFrom<PgNumeric> for Decimal

Sourceยง

type Error = Box<dyn Error + Send + Sync>

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

fn try_from(numeric: PgNumeric) -> Result<Decimal, Box<dyn Error + Send + Sync>>

Performs the conversion.
Sourceยง

impl TryFrom<f32> for Decimal

Try to convert a f32 into a Decimal.

Can fail if the value is out of range for Decimal.

Sourceยง

type Error = Error

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

fn try_from(t: f32) -> Result<Decimal, Error>

Performs the conversion.
Sourceยง

impl TryFrom<f64> for Decimal

Try to convert a f64 into a Decimal.

Can fail if the value is out of range for Decimal.

Sourceยง

type Error = Error

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

fn try_from(t: f64) -> Result<Decimal, Error>

Performs the conversion.
Sourceยง

impl Type<Any> for Decimal

Sourceยง

fn type_info() -> AnyTypeInfo

Returns the canonical SQL type for this Rust type. Read more
Sourceยง

fn compatible(ty: &AnyTypeInfo) -> bool

Determines if this Rust type is compatible with the given SQL type. Read more
Sourceยง

impl Type<Mssql> for Decimal

Sourceยง

fn type_info() -> MssqlTypeInfo

Returns the canonical SQL type for this Rust type. Read more
Sourceยง

fn compatible(ty: &MssqlTypeInfo) -> bool

Determines if this Rust type is compatible with the given SQL type. Read more
Sourceยง

impl Type<MySql> for Decimal

Sourceยง

fn type_info() -> MySqlTypeInfo

Returns the canonical SQL type for this Rust type. Read more
Sourceยง

fn compatible(ty: &<DB as Database>::TypeInfo) -> bool

Determines if this Rust type is compatible with the given SQL type. Read more
Sourceยง

impl Type<Postgres> for Decimal

Sourceยง

fn type_info() -> PgTypeInfo

Returns the canonical SQL type for this Rust type. Read more
Sourceยง

fn compatible(ty: &<DB as Database>::TypeInfo) -> bool

Determines if this Rust type is compatible with the given SQL type. Read more
Sourceยง

impl Type<Sqlite> for Decimal

Sourceยง

fn type_info() -> SqliteTypeInfo

Returns the canonical SQL type for this Rust type. Read more
Sourceยง

fn compatible(ty: &SqliteTypeInfo) -> bool

Determines if this Rust type is compatible with the given SQL type. Read more
Sourceยง

impl UpperExp for Decimal

Sourceยง

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

Formats the value using the given formatter. Read more
Sourceยง

impl Zero for Decimal

Sourceยง

fn zero() -> Decimal

Returns the additive identity element of Self, 0. Read more
Sourceยง

fn is_zero(&self) -> bool

Returns true if self is equal to the additive identity.
Sourceยง

fn set_zero(&mut self)

Sets self to the additive identity element of Self, 0.
Sourceยง

impl Copy for Decimal

Sourceยง

impl Eq for Decimal

Auto Trait Implementationsยง

Blanket Implementationsยง

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<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<Q, K> Comparable<K> for Q
where Q: Ord + ?Sized, K: Borrow<Q> + ?Sized,

Sourceยง

fn compare(&self, key: &K) -> Ordering

Compare self to key and return their ordering.
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<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Sourceยง

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

Compare self to key and return true if they are equal.
Sourceยง

impl<T> From<T> for T

Sourceยง

fn from(t: T) -> T

Returns the argument unchanged.

Sourceยง

impl<I> FromRadix10 for I
where I: Zero + One + AddAssign + MulAssign,

Sourceยง

fn from_radix_10(text: &[u8]) -> (I, usize)

Parses an integer from a slice. Read more
Sourceยง

impl<I> FromRadix10Signed for I

Sourceยง

fn from_radix_10_signed(text: &[u8]) -> (I, usize)

Parses an integer from a slice. Read more
Sourceยง

impl<I> FromRadix16 for I
where I: Zero + One + AddAssign + MulAssign,

Sourceยง

fn from_radix_16(text: &[u8]) -> (I, usize)

Parses an integer from a slice. Read more
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> IntoEither for T

Sourceยง

fn into_either(self, into_left: bool) -> Either<Self, Self> โ“˜

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Sourceยง

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> โ“˜
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Sourceยง

impl<T> Same for T

Sourceยง

type Output = T

Should always be Self
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 = Infallible

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

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

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.
Sourceยง

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Sourceยง

fn vzip(self) -> V

Sourceยง

impl<'r, T> AnyDecode<'r> for T
where T: Decode<'r, Postgres> + Type<Postgres> + Decode<'r, MySql> + Type<MySql> + Decode<'r, Mssql> + Type<Mssql> + Decode<'r, Sqlite> + Type<Sqlite>,

Sourceยง

impl<'q, T> AnyEncode<'q> for T
where T: Encode<'q, Postgres> + Type<Postgres> + Encode<'q, MySql> + Type<MySql> + Encode<'q, Mssql> + Type<Mssql> + Encode<'q, Sqlite> + Type<Sqlite>,

Sourceยง

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

Sourceยง

impl<T> ErasedDestructor for T
where T: 'static,

Sourceยง

impl<T> NumAssign for T
where T: Num + NumAssignOps,

Sourceยง

impl<T, Rhs> NumAssignOps<Rhs> for T
where T: AddAssign<Rhs> + SubAssign<Rhs> + MulAssign<Rhs> + DivAssign<Rhs> + RemAssign<Rhs>,

Sourceยง

impl<T> NumAssignRef for T
where T: NumAssign + for<'r> NumAssignOps<&'r T>,

Sourceยง

impl<T, Rhs, Output> NumOps<Rhs, Output> for T
where T: Sub<Rhs, Output = Output> + Mul<Rhs, Output = Output> + Div<Rhs, Output = Output> + Add<Rhs, Output = Output> + Rem<Rhs, Output = Output>,

Sourceยง

impl<T> NumRef for T
where T: Num + for<'r> NumOps<&'r T>,

Sourceยง

impl<T, Base> RefNum<Base> for T
where T: NumOps<Base, Base> + for<'r> NumOps<&'r Base, Base>,