# Struct rust_decimal::Decimal

``#[repr(C)]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 PI: Decimal = _

Available on crate feature `maths` only.

A constant representing π as 3.1415926535897932384626433833

##### §Examples

Basic usage:

``assert_eq!(Decimal::PI, dec!(3.1415926535897932384626433833));``
source

#### pub const HALF_PI: Decimal = _

Available on crate feature `maths` only.

A constant representing π/2 as 1.5707963267948966192313216916

##### §Examples

Basic usage:

``assert_eq!(Decimal::HALF_PI, dec!(1.5707963267948966192313216916));``
source

#### pub const QUARTER_PI: Decimal = _

Available on crate feature `maths` only.

A constant representing π/4 as 0.7853981633974483096156608458

##### §Examples

Basic usage:

``assert_eq!(Decimal::QUARTER_PI, dec!(0.7853981633974483096156608458));``
source

#### pub const TWO_PI: Decimal = _

Available on crate feature `maths` only.

A constant representing 2π as 6.2831853071795864769252867666

##### §Examples

Basic usage:

``assert_eq!(Decimal::TWO_PI, dec!(6.2831853071795864769252867666));``
source

#### pub const E: Decimal = _

Available on crate feature `maths` only.

A constant representing Euler’s number (e) as 2.7182818284590452353602874714

##### §Examples

Basic usage:

``assert_eq!(Decimal::E, dec!(2.7182818284590452353602874714));``
source

#### pub const E_INVERSE: Decimal = _

Available on crate feature `maths` only.

A constant representing the inverse of Euler’s number (1/e) as 0.3678794411714423215955237702

##### §Examples

Basic usage:

``assert_eq!(Decimal::E_INVERSE, dec!(0.3678794411714423215955237702));``
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 > 28.

##### §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>

Checked version of `Decimal::new`. Will return `Err` 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 > 28 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>

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 28.
##### §Caution: Undefined behavior

While a scale greater than 28 can be passed in, it will be automatically capped by this function at the maximum precision. The library opts towards this functionality as opposed to a panic to ensure that the function can be treated as constant. This may lead to undefined behavior in downstream applications and should be treated with caution.

##### §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

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<Self, 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
``````use rust_decimal_macros::dec;

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 `Decimal`s 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 `Decimal::MAX_PRECISION` 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
``````use rust_decimal_macros::dec;

// 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`

##### §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
``````use rust_decimal_macros::dec;

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
``````use rust_decimal_macros::dec;

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
``````use rust_decimal_macros::dec;

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<Self>

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<Self>

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<'a, 'b> Add<&'b Decimal> for &'a Decimal

§

#### 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

§

#### 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

§

#### type Output = Decimal

The resulting type after applying the `+` operator.
source§

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

Performs the `+` operation. Read more
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<'a> AddAssign<Decimal> for &'a mut Decimal

source§

#### fn add_assign(&mut self, other: Decimal)

Performs the `+=` operation. Read more
source§

source§

#### fn add_assign(&mut self, other: Decimal)

Performs the `+=` operation. Read more
source§

### impl Arbitrary<'_> for Decimal

Available on crate feature `rust-fuzz` only.
source§

#### fn arbitrary(u: &mut Unstructured<'_>) -> ArbitraryResult<Self>

Generate an arbitrary value of `Self` from the given unstructured data. Read more
source§

#### fn arbitrary_take_rest(u: Unstructured<'a>) -> Result<Self, Error>

Generate an arbitrary value of `Self` from the entirety of the given unstructured data. Read more
source§

#### fn size_hint(depth: usize) -> (usize, Option<usize>)

Get a size hint for how many bytes out of an `Unstructured` this type needs to construct itself. Read more
source§

### impl Arbitrary for Decimal

Available on crate feature `proptest` only.
§

#### type Parameters = ()

The type of parameters that `arbitrary_with` accepts for configuration of the generated `Strategy`. Parameters must implement `Default`.
§

#### type Strategy = FilterMap<<(u32, u32, u32, bool, u8) as Arbitrary>::Strategy, fn(_: (u32, u32, u32, bool, u8)) -> Option<Decimal>>

The type of `Strategy` used to generate values of type `Self`.
source§

#### fn arbitrary_with(_parameters: Self::Parameters) -> Self::Strategy

Generates a `Strategy` for producing arbitrary values of type the implementing type (`Self`). The strategy is passed the arguments given in args. Read more
source§

#### fn arbitrary() -> Self::Strategy

Generates a `Strategy` for producing arbitrary values of type the implementing type (`Self`). Read more
source§

### impl Archive for Decimalwhere u32: Archive,

§

#### type Archived = ArchivedDecimal

The archived representation of this type. Read more
§

#### type Resolver = DecimalResolver

The resolver for this type. It must contain all the additional information from serializing needed to make the archived type from the normal type.
source§

#### unsafe fn resolve( &self, pos: usize, resolver: Self::Resolver, out: *mut Self::Archived )

Creates the archived version of this value at the given position and writes it to the given output. Read more
source§

### impl<'expr> AsExpression<Nullable<Numeric>> for &'expr Decimal

§

#### type Expression = Bound<Nullable<Numeric>, &'expr Decimal>

The expression being returned
source§

#### fn as_expression(self) -> Self::Expression

Perform the conversion
source§

### impl AsExpression<Nullable<Numeric>> for Decimal

§

#### type Expression = Bound<Nullable<Numeric>, Decimal>

The expression being returned
source§

#### fn as_expression(self) -> Self::Expression

Perform the conversion
source§

### impl<'expr> AsExpression<Numeric> for &'expr Decimal

§

#### type Expression = Bound<Numeric, &'expr Decimal>

The expression being returned
source§

#### fn as_expression(self) -> Self::Expression

Perform the conversion
source§

### impl AsExpression<Numeric> for Decimal

§

#### type Expression = Bound<Numeric, Decimal>

The expression being returned
source§

#### fn as_expression(self) -> Self::Expression

Perform the conversion
source§

### impl BorshDeserialize for Decimal

source§

source§

#### fn deserialize(buf: &mut &[u8]) -> Result<Self, Error>

Deserializes this instance from a given slice of bytes. Updates the buffer to point at the remaining bytes.
source§

#### fn try_from_slice(v: &[u8]) -> Result<Self, Error>

Deserialize this instance from a slice of bytes.
source§

source§

### impl BorshSchema for Decimal

source§

#### fn declaration() -> Declaration

Get the name of the type without brackets.
source§

#### fn add_definitions_recursively( definitions: &mut BTreeMap<Declaration, Definition> )

Recursively, using DFS, add type definitions required for this type. Type definition partially explains how to serialize/deserialize a type.
source§

### impl BorshSerialize for Decimal

source§

source§

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 copy 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 Default for Decimal

source§

#### fn default() -> Self

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

source§

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

Available on crate feature `serde` and (crate features `serde-with-str` or `serde-with-float` or `serde-with-arbitrary-precision`) and crate feature `serde-str` and crate feature `serde-float` only.
source§

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

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

### impl<__D: Fallible + ?Sized> Deserialize<Decimal, __D> for Archived<Decimal>where u32: Archive, Archived<u32>: Deserialize<u32, __D>,

source§

#### fn deserialize(&self, deserializer: &mut __D) -> Result<Decimal, __D::Error>

Deserializes using the given deserializer
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 Distribution<Decimal> for Standard

Available on crate feature `rand` only.
source§

#### fn sample<R>(&self, rng: &mut R) -> Decimalwhere R: Rng + ?Sized,

Generate a random value of `T`, using `rng` as the source of randomness.
source§

#### fn sample_iter<R>(self, rng: R) -> DistIter<Self, R, T>where R: Rng, Self: Sized,

Create an iterator that generates random values of `T`, using `rng` as the source of randomness. Read more
source§

#### fn map<F, S>(self, func: F) -> DistMap<Self, F, T, S>where F: Fn(T) -> S, Self: Sized,

Create a distribution of values of ‘S’ by mapping the output of `Self` through the closure `F` Read more
source§

### impl<'a, 'b> Div<&'b Decimal> for &'a Decimal

§

#### 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

§

#### 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

§

#### 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

§

#### 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<'a> DivAssign<Decimal> for &'a 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<'a> From<&'a Decimal> for PgNumeric

Available on (crate features `db-diesel1-postgres` or `db-diesel2-postgres`) and (crate features `db-tokio-postgres` or `db-postgres` or `db-diesel1-postgres` or `db-diesel2-postgres`) only.
source§

#### fn from(decimal: &'a Decimal) -> Self

Converts to this type from the input type.
source§

### impl From<Decimal> for PgNumeric

Available on (crate features `db-diesel1-postgres` or `db-diesel2-postgres`) and (crate features `db-tokio-postgres` or `db-postgres` or `db-diesel1-postgres` or `db-diesel2-postgres`) only.
source§

#### fn from(decimal: Decimal) -> Self

Converts to this type from the input type.
source§

### impl From<i128> for Decimal

Conversion to `Decimal`.

source§

#### fn from(t: i128) -> Self

Converts to this type from the input type.
source§

### impl From<i16> for Decimal

Conversion to `Decimal`.

source§

#### fn from(t: i16) -> Self

Converts to this type from the input type.
source§

### impl From<i32> for Decimal

Conversion to `Decimal`.

source§

#### fn from(t: i32) -> Self

Converts to this type from the input type.
source§

### impl From<i64> for Decimal

Conversion to `Decimal`.

source§

#### fn from(t: i64) -> Self

Converts to this type from the input type.
source§

### impl From<i8> for Decimal

Conversion to `Decimal`.

source§

#### fn from(t: i8) -> Self

Converts to this type from the input type.
source§

### impl From<isize> for Decimal

Conversion to `Decimal`.

source§

#### fn from(t: isize) -> Self

Converts to this type from the input type.
source§

### impl From<u128> for Decimal

Conversion to `Decimal`.

source§

#### fn from(t: u128) -> Self

Converts to this type from the input type.
source§

### impl From<u16> for Decimal

Conversion to `Decimal`.

source§

#### fn from(t: u16) -> Self

Converts to this type from the input type.
source§

### impl From<u32> for Decimal

Conversion to `Decimal`.

source§

#### fn from(t: u32) -> Self

Converts to this type from the input type.
source§

### impl From<u64> for Decimal

Conversion to `Decimal`.

source§

#### fn from(t: u64) -> Self

Converts to this type from the input type.
source§

### impl From<u8> for Decimal

Conversion to `Decimal`.

source§

#### fn from(t: u8) -> Self

Converts to this type from the input type.
source§

### impl From<usize> for Decimal

Conversion to `Decimal`.

source§

#### fn from(t: usize) -> Self

Converts to this type from the input type.
source§

### impl<'v> FromFormField<'v> for Decimal

Available on crate feature `rocket-traits` only.
source§

#### fn default() -> Option<Self>

Returns a default value, if any exists, to be used during lenient parsing when the form field is missing. Read more
source§

#### fn from_value(field: ValueField<'v>) -> Result<'v, Self>

Parse a value of `T` from a form value field. Read more
source§

#### fn from_data<'life0, 'async_trait>( field: DataField<'v, 'life0> ) -> Pin<Box<dyn Future<Output = Result<Self, Errors<'v>>> + Send + 'async_trait>>where 'v: 'async_trait, 'life0: 'async_trait, Self: 'async_trait,

Parse a value of `T` from a form data field. Read more
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<'a> FromSql<'a> for Decimal

Available on (crate features `db-postgres` or `db-tokio-postgres`) and (crate features `db-tokio-postgres` or `db-postgres` or `db-diesel1-postgres` or `db-diesel2-postgres`) only.
source§

#### fn from_sql( _: &Type, raw: &[u8] ) -> Result<Decimal, Box<dyn Error + Sync + Send + 'static>>

Creates a new value of this type from a buffer of data of the specified Postgres `Type` in its binary format. Read more
source§

#### fn accepts(ty: &Type) -> bool

Determines if a value of this type can be created from the specified Postgres `Type`.
source§

#### fn from_sql_null(ty: &Type) -> Result<Self, Box<dyn Error + Send + Sync>>

Creates a new value of this type from a `NULL` SQL value. Read more
source§

#### fn from_sql_nullable( ty: &Type, raw: Option<&'a [u8]> ) -> Result<Self, Box<dyn Error + Send + Sync>>

A convenience function that delegates to `from_sql` and `from_sql_null` depending on the value of `raw`.
source§

### impl FromSql<Numeric, Mysql> for Decimal

Available on (crate features `db-diesel1-mysql` or `db-diesel2-mysql`) and crate feature `diesel2` only.
source§

#### fn from_sql(numeric: MysqlValue<'_>) -> Result<Self>

See the trait documentation.
source§

#### fn from_nullable_sql( bytes: Option<<DB as Backend>::RawValue<'_>> ) -> Result<Self, Box<dyn Error + Send + Sync>>

A specialized variant of `from_sql` for handling null values. Read more
source§

### impl FromSql<Numeric, Pg> for Decimal

Available on (crate features `db-diesel1-postgres` or `db-diesel2-postgres`) and (crate features `db-tokio-postgres` or `db-postgres` or `db-diesel1-postgres` or `db-diesel2-postgres`) and crate feature `diesel2` only.
source§

#### fn from_sql(numeric: PgValue<'_>) -> Result<Self>

See the trait documentation.
source§

#### fn from_nullable_sql( bytes: Option<<DB as Backend>::RawValue<'_>> ) -> Result<Self, Box<dyn Error + Send + Sync>>

A specialized variant of `from_sql` for handling null values. Read more
source§

### impl FromStr for Decimal

§

#### type Err = Error

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

#### fn from_str(value: &str) -> Result<Decimal, Self::Err>

Parses a string `s` to return a value of this type. Read more
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 Inv for Decimal

§

#### type Output = Decimal

The result after applying the operator.
source§

#### fn inv(self) -> Self

Returns the multiplicative inverse of `self`. Read more
source§

### impl LowerExp for Decimal

source§

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

Formats the value using the given formatter.
source§

### impl MathematicalOps for Decimal

Available on crate feature `maths` only.
source§

#### fn exp(&self) -> Decimal

The estimated exponential function, ex. Stops calculating when it is within tolerance of roughly `0.0000002`.
source§

#### fn checked_exp(&self) -> Option<Decimal>

The estimated exponential function, ex. Stops calculating when it is within tolerance of roughly `0.0000002`. Returns `None` on overflow.
source§

#### fn exp_with_tolerance(&self, tolerance: Decimal) -> Decimal

The estimated exponential function, ex using the `tolerance` provided as a hint as to when to stop calculating. A larger tolerance will cause the number to stop calculating sooner at the potential cost of a slightly less accurate result.
source§

#### fn checked_exp_with_tolerance(&self, tolerance: Decimal) -> Option<Decimal>

The estimated exponential function, ex using the `tolerance` provided as a hint as to when to stop calculating. A larger tolerance will cause the number to stop calculating sooner at the potential cost of a slightly less accurate result. Returns `None` on overflow.
source§

#### fn powi(&self, exp: i64) -> Decimal

Raise self to the given integer exponent: xy
source§

#### fn checked_powi(&self, exp: i64) -> Option<Decimal>

Raise self to the given integer exponent xy returning `None` on overflow.
source§

#### fn powu(&self, exp: u64) -> Decimal

Raise self to the given unsigned integer exponent: xy
source§

#### fn checked_powu(&self, exp: u64) -> Option<Decimal>

Raise self to the given unsigned integer exponent xy returning `None` on overflow.
source§

#### fn powf(&self, exp: f64) -> Decimal

Raise self to the given floating point exponent: xy
source§

#### fn checked_powf(&self, exp: f64) -> Option<Decimal>

Raise self to the given floating point exponent xy returning `None` on overflow.
source§

#### fn powd(&self, exp: Decimal) -> Decimal

Raise self to the given Decimal exponent: xy. If `exp` is not whole then the approximation ey*ln(x) is used.
source§

#### fn checked_powd(&self, exp: Decimal) -> Option<Decimal>

Raise self to the given Decimal exponent xy returning `None` on overflow. If `exp` is not whole then the approximation ey*ln(x) is used.
source§

#### fn sqrt(&self) -> Option<Decimal>

The square root of a Decimal. Uses a standard Babylonian method.
source§

#### fn ln(&self) -> Decimal

Calculates the natural logarithm for a Decimal calculated using Taylor’s series.
source§

#### fn checked_ln(&self) -> Option<Decimal>

Calculates the checked natural logarithm for a Decimal calculated using Taylor’s series. Returns `None` for negative numbers or zero.
source§

#### fn log10(&self) -> Decimal

Calculates the base 10 logarithm of a specified Decimal number.
source§

#### fn checked_log10(&self) -> Option<Decimal>

Calculates the checked base 10 logarithm of a specified Decimal number. Returns `None` for negative numbers or zero.
source§

#### fn erf(&self) -> Decimal

Abramowitz Approximation of Error Function from wikipedia
source§

#### fn norm_cdf(&self) -> Decimal

The Cumulative distribution function for a Normal distribution
source§

#### fn norm_pdf(&self) -> Decimal

The Probability density function for a Normal distribution.
source§

#### fn checked_norm_pdf(&self) -> Option<Decimal>

The Probability density function for a Normal distribution returning `None` on overflow.
source§

#### fn sin(&self) -> Decimal

Computes the sine of a number (in radians). Panics upon overflow.
source§

#### fn checked_sin(&self) -> Option<Decimal>

Computes the checked sine of a number (in radians).
source§

#### fn cos(&self) -> Decimal

Computes the cosine of a number (in radians). Panics upon overflow.
source§

#### fn checked_cos(&self) -> Option<Decimal>

Computes the checked cosine of a number (in radians).
source§

#### fn tan(&self) -> Decimal

Computes the tangent of a number (in radians). Panics upon overflow or upon approaching a limit.
source§

#### fn checked_tan(&self) -> Option<Decimal>

Computes the checked tangent of a number (in radians). Returns None on limit.
source§

### impl<'a, 'b> Mul<&'b Decimal> for &'a Decimal

§

#### 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

§

#### 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

§

#### 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

§

#### 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<'a> MulAssign<Decimal> for &'a 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<'a> Neg for &'a Decimal

§

#### 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

§

#### 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§

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) -> boolwhere 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) -> Selfwhere Self: Sized,

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

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

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

#### fn clamp(self, min: Self, max: Self) -> Selfwhere Self: Sized + PartialOrd,

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

### impl PartialEq for Decimal

source§

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

This method tests for `self` and `other` values to be equal, and is used by `==`.
1.0.0 · source§

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

This method 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

This method 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

This method 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

This method 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

This method tests greater than or equal to (for `self` and `other`) and is used by the `>=` operator. Read more
source§

### impl Pow<Decimal> for Decimal

Available on crate feature `maths` only.
§

#### type Output = Decimal

The result after applying the operator.
source§

#### fn pow(self, rhs: Decimal) -> Self::Output

Returns `self` to the power `rhs`. Read more
source§

### impl Pow<f64> for Decimal

Available on crate feature `maths` only.
§

#### type Output = Decimal

The result after applying the operator.
source§

#### fn pow(self, rhs: f64) -> Self::Output

Returns `self` to the power `rhs`. Read more
source§

### impl Pow<i64> for Decimal

Available on crate feature `maths` only.
§

#### type Output = Decimal

The result after applying the operator.
source§

#### fn pow(self, rhs: i64) -> Self::Output

Returns `self` to the power `rhs`. Read more
source§

### impl Pow<u64> for Decimal

Available on crate feature `maths` only.
§

#### type Output = Decimal

The result after applying the operator.
source§

#### fn pow(self, rhs: u64) -> Self::Output

Returns `self` to the power `rhs`. Read more
source§

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

source§

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

Panics if out-of-bounds

source§

### impl Product for Decimal

source§

#### fn product<I: Iterator<Item = Decimal>>(iter: I) -> Self

Panics if out-of-bounds

source§

### impl<__ST, __DB> Queryable<__ST, __DB> for Decimalwhere __DB: Backend, __ST: SingleValue, Self: FromSql<__ST, __DB>,

§

#### type Row = Decimal

The Rust type you’d like to map from. Read more
source§

#### fn build(row: Self::Row) -> Result<Self>

Construct an instance of this type
source§

### impl<'a, 'b> Rem<&'b Decimal> for &'a Decimal

§

#### 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

§

#### 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

§

#### 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

§

#### 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<'a> RemAssign<Decimal> for &'a 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 SampleUniform for Decimal

Available on crate feature `rand` only.
§

#### type Sampler = DecimalSampler

The `UniformSampler` implementation supporting type `X`.
source§

### impl<__S: Fallible + ?Sized> Serialize<__S> for Decimalwhere u32: Serialize<__S>,

source§

#### fn serialize(&self, serializer: &mut __S) -> Result<Self::Resolver, __S::Error>

Writes the dependencies for the object and returns a resolver that can create the archived type.
source§

### impl Serialize for Decimal

Available on crate feature `serde` and (crate features `serde-with-str` or `serde-with-float` or `serde-with-arbitrary-precision`) and crate feature `serde-float` and crate feature `serde-arbitrary-precision` only.
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 Signed for Decimal

source§

#### fn abs(&self) -> Self

Computes the absolute value. Read more
source§

#### fn abs_sub(&self, other: &Self) -> Self

The positive difference of two numbers. Read more
source§

#### fn signum(&self) -> Self

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<'a, 'b> Sub<&'b Decimal> for &'a Decimal

§

#### 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

§

#### 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

§

#### 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

§

#### 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<'a> SubAssign<Decimal> for &'a 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: Iterator<Item = &'a Decimal>>(iter: I) -> Self

Method which takes an iterator and generates `Self` from the elements by “summing up” the items.
source§

### impl Sum for Decimal

source§

#### fn sum<I: Iterator<Item = Decimal>>(iter: I) -> Self

Method which 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<__DB> ToSql<Nullable<Numeric>, __DB> for Decimalwhere __DB: Backend, Self: ToSql<Numeric, __DB>,

source§

#### fn to_sql<'__b>(&'__b self, out: &mut Output<'__b, '_, __DB>) -> Result

See the trait documentation.
source§

### impl ToSql<Numeric, Mysql> for Decimal

Available on (crate features `db-diesel1-mysql` or `db-diesel2-mysql`) and crate feature `diesel2` only.
source§

#### fn to_sql<'b>(&'b self, out: &mut Output<'b, '_, Mysql>) -> Result

See the trait documentation.
source§

### impl ToSql<Numeric, Pg> for Decimal

Available on (crate features `db-diesel1-postgres` or `db-diesel2-postgres`) and (crate features `db-tokio-postgres` or `db-postgres` or `db-diesel1-postgres` or `db-diesel2-postgres`) and crate feature `diesel2` only.
source§

#### fn to_sql<'b>(&'b self, out: &mut Output<'b, '_, Pg>) -> Result

See the trait documentation.
source§

### impl ToSql for Decimal

Available on (crate features `db-postgres` or `db-tokio-postgres`) and (crate features `db-tokio-postgres` or `db-postgres` or `db-diesel1-postgres` or `db-diesel2-postgres`) only.
source§

#### fn to_sql( &self, _: &Type, out: &mut BytesMut ) -> Result<IsNull, Box<dyn Error + Sync + Send + 'static>>

Converts the value of `self` into the binary format of the specified Postgres `Type`, appending it to `out`. Read more
source§

#### fn accepts(ty: &Type) -> bool

Determines if a value of this type can be converted to the specified Postgres `Type`.
source§

source§

#### fn encode_format(&self, _ty: &Type) -> Format

Specify the encode format
source§

### impl<'a> TryFrom<&'a PgNumeric> for Decimal

Available on (crate features `db-diesel1-postgres` or `db-diesel2-postgres`) and (crate features `db-tokio-postgres` or `db-postgres` or `db-diesel1-postgres` or `db-diesel2-postgres`) only.
§

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

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

#### fn try_from(numeric: &'a PgNumeric) -> Result<Self>

Performs the conversion.
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`.

§

#### type Error = Error

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

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

Performs the conversion.
source§

### impl TryFrom<Decimal> for f32

Try to convert a `Decimal` to `f32`.

Can fail if the `Decimal` is out of range for `f32`.

§

#### type Error = Error

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

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

Performs the conversion.
source§

### impl TryFrom<Decimal> for f64

Try to convert a `Decimal` to `f64`.

Can fail if the `Decimal` is out of range for `f64`.

§

#### type Error = Error

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

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

Performs the conversion.
source§

### impl TryFrom<Decimal> for i128

Try to convert a `Decimal` to `i128` by truncating and returning the integer component.

Can fail if the `Decimal` is out of range for `i128`.

§

#### type Error = Error

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

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

Performs the conversion.
source§

### impl TryFrom<Decimal> for i16

Try to convert a `Decimal` to `i16` by truncating and returning the integer component.

Can fail if the `Decimal` is out of range for `i16`.

§

#### type Error = Error

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

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

Performs the conversion.
source§

### impl TryFrom<Decimal> for i32

Try to convert a `Decimal` to `i32` by truncating and returning the integer component.

Can fail if the `Decimal` is out of range for `i32`.

§

#### type Error = Error

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

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

Performs the conversion.
source§

### impl TryFrom<Decimal> for i64

Try to convert a `Decimal` to `i64` by truncating and returning the integer component.

Can fail if the `Decimal` is out of range for `i64`.

§

#### type Error = Error

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

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

Performs the conversion.
source§

### impl TryFrom<Decimal> for i8

Try to convert a `Decimal` to `i8` by truncating and returning the integer component.

Can fail if the `Decimal` is out of range for `i8`.

§

#### type Error = Error

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

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

Performs the conversion.
source§

### impl TryFrom<Decimal> for isize

Try to convert a `Decimal` to `isize` by truncating and returning the integer component.

Can fail if the `Decimal` is out of range for `isize`.

§

#### type Error = Error

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

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

Performs the conversion.
source§

### impl TryFrom<Decimal> for u128

Try to convert a `Decimal` to `u128` by truncating and returning the integer component.

Can fail if the `Decimal` is out of range for `u128`.

§

#### type Error = Error

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

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

Performs the conversion.
source§

### impl TryFrom<Decimal> for u16

Try to convert a `Decimal` to `u16` by truncating and returning the integer component.

Can fail if the `Decimal` is out of range for `u16`.

§

#### type Error = Error

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

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

Performs the conversion.
source§

### impl TryFrom<Decimal> for u32

Try to convert a `Decimal` to `u32` by truncating and returning the integer component.

Can fail if the `Decimal` is out of range for `u32`.

§

#### type Error = Error

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

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

Performs the conversion.
source§

### impl TryFrom<Decimal> for u64

Try to convert a `Decimal` to `u64` by truncating and returning the integer component.

Can fail if the `Decimal` is out of range for `u64`.

§

#### type Error = Error

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

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

Performs the conversion.
source§

### impl TryFrom<Decimal> for u8

Try to convert a `Decimal` to `u8` by truncating and returning the integer component.

Can fail if the `Decimal` is out of range for `u8`.

§

#### type Error = Error

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

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

Performs the conversion.
source§

### impl TryFrom<Decimal> for usize

Try to convert a `Decimal` to `usize` by truncating and returning the integer component.

Can fail if the `Decimal` is out of range for `usize`.

§

#### type Error = Error

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

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

Performs the conversion.
source§

### impl TryFrom<PgNumeric> for Decimal

Available on (crate features `db-diesel1-postgres` or `db-diesel2-postgres`) and (crate features `db-tokio-postgres` or `db-postgres` or `db-diesel1-postgres` or `db-diesel2-postgres`) only.
§

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

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

#### fn try_from(numeric: PgNumeric) -> Result<Self>

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`.

§

#### type Error = Error

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

#### fn try_from(t: f32) -> Result<Self, 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`.

§

#### type Error = Error

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

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

Performs the conversion.
source§

### impl UpperExp for Decimal

source§

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

Formats the value using the given formatter.
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§

source§

source§

### impl ScalarOperand for Decimal

Available on crate feature `ndarray` only.

§

§

§

§

§

§

## Blanket Implementations§

source§

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

source§

#### fn type_id(&self) -> TypeId

Gets the `TypeId` of `self`. Read more
source§

### impl<T> ArchivePointee for T

§

The archived version of the pointer metadata for this type.
source§

source§

### impl<T> ArchiveUnsized for Twhere T: Archive,

§

#### type Archived = <T as Archive>::Archived

The archived counterpart of this type. Unlike `Archive`, it may be unsized. Read more
§

source§

#### unsafe fn resolve_metadata( &self, _: usize, _: <T as ArchiveUnsized>::MetadataResolver, _: *mut <<T as ArchiveUnsized>::Archived as ArchivePointee>::ArchivedMetadata )

Creates the archived version of the metadata for this value at the given position and writes it to the given output. Read more
source§

#### unsafe fn resolve_unsized( &self, from: usize, to: usize, resolver: Self::MetadataResolver, out: *mut RelPtr<Self::Archived, <isize as Archive>::Archived> )

Resolves a relative pointer to this value with the given `from` and `to` and writes it to the given output. Read more
source§

### impl<T> Borrow<T> for Twhere T: ?Sized,

source§

#### fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

### impl<T> BorrowMut<T> for Twhere T: ?Sized,

source§

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

Mutably borrows from an owned value. Read more
source§

### impl<T> BorrowToSql for Twhere T: ToSql,

source§

#### fn borrow_to_sql(&self) -> &dyn ToSql

Returns a reference to `self` as a `ToSql` trait object.
source§

source§

source§

### impl<Q, K> Comparable<K> for Qwhere Q: Ord + ?Sized, K: Borrow<Q> + ?Sized,

source§

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

Compare self to `key` and return their ordering.
source§

### impl<F, W, T, D> Deserialize<With<T, W>, D> for Fwhere W: DeserializeWith<F, T, D>, D: Fallible + ?Sized, F: ?Sized,

source§

#### fn deserialize( &self, deserializer: &mut D ) -> Result<With<T, W>, <D as Fallible>::Error>

Deserializes using the given deserializer
source§

### impl<Q, K> Equivalent<K> for Qwhere 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 Qwhere 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<'v, T> FromForm<'v> for Twhere T: FromFormField<'v>,

§

#### type Context = FromFieldContext<'v, T>

The form guard’s parsing context.
source§

#### fn init(opts: Options) -> <T as FromForm<'v>>::Context

Initializes and returns the parsing context for `Self`.
source§

#### fn push_value(ctxt: &mut <T as FromForm<'v>>::Context, field: ValueField<'v>)

Processes the value field `field`.
source§

#### fn push_data<'life0, 'life1, 'async_trait>( ctxt: &'life0 mut FromFieldContext<'v, T>, field: DataField<'v, 'life1> ) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>where 'v: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, T: 'async_trait,

Processes the data field `field`.
source§

#### fn finalize(ctxt: <T as FromForm<'v>>::Context) -> Result<T, Errors<'v>>

Finalizes parsing. Returns the parsed value when successful or collection of `Errors` otherwise.
source§

#### fn push_error(_ctxt: &mut Self::Context, _error: Error<'r>)

Processes the external form or field error `_error`. Read more
source§

#### fn default(opts: Options) -> Option<Self>

Returns a default value, if any, to use when a value is desired and parsing fails. Read more
source§

### impl<T, ST, DB> FromSqlRow<ST, DB> for Twhere T: Queryable<ST, DB>, ST: SqlTypeOrSelectable, DB: Backend, <T as Queryable<ST, DB>>::Row: FromStaticSqlRow<ST, DB>,

source§

#### fn build_from_row<'a>( row: &impl Row<'a, DB> ) -> Result<T, Box<dyn Error + Send + Sync>>

See the trait documentation.
source§

### impl<T, ST, DB> FromStaticSqlRow<ST, DB> for Twhere DB: Backend, T: FromSql<ST, DB>, ST: SingleValue,

source§

#### fn build_from_row<'a>( row: &impl Row<'a, DB> ) -> Result<T, Box<dyn Error + Send + Sync>>

See the trait documentation
source§

### impl<T> Instrument for T

source§

#### fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided `Span`, returning an `Instrumented` wrapper. Read more
source§

#### fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current `Span`, returning an `Instrumented` wrapper. Read more
source§

### impl<T, U> Into<U> for Twhere 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> IntoCollection<T> for T

source§

#### fn into_collection<A>(self) -> SmallVec<A>where A: Array<Item = T>,

Converts `self` into a collection.
source§

source§

### impl<T> IntoSql for T

source§

#### fn into_sql<T>(self) -> Self::Expressionwhere Self: AsExpression<T> + Sized, T: SqlType + TypedExpressionType,

Convert `self` to an expression for Diesel’s query builder. Read more
source§

#### fn as_sql<'a, T>(&'a self) -> <&'a Self as AsExpression<T>>::Expressionwhere &'a Self: AsExpression<T>, T: SqlType + TypedExpressionType,

Convert `&self` to an expression for Diesel’s query builder. Read more
source§

### impl<T> LayoutRaw for T

source§

#### fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>

Gets the layout of the type.
source§

### impl<T> Paint for Twhere T: ?Sized,

source§

#### fn fg(&self, value: Color) -> Painted<&T>

Returns a styled value derived from `self` with the foreground set to `value`.

This method should be used rarely. Instead, prefer to use color-specific builder methods like `red()` and `green()`, which have the same functionality but are pithier.

##### §Example

Set foreground color to white using `fg()`:

``````use yansi::{Paint, Color};

painted.fg(Color::White);``````

Set foreground color to white using `white()`.

``````use yansi::Paint;

painted.white();``````
source§

#### fn primary(&self) -> Painted<&T>

Returns `self` with the `fg()` set to `Color::Primary`.

##### §Example
``println!("{}", value.primary());``
source§

#### fn fixed(&self, color: u8) -> Painted<&T>

Returns `self` with the `fg()` set to `Color::Fixed`.

##### §Example
``println!("{}", value.fixed(color));``
source§

#### fn rgb(&self, r: u8, g: u8, b: u8) -> Painted<&T>

Returns `self` with the `fg()` set to `Color::Rgb`.

##### §Example
``println!("{}", value.rgb(r, g, b));``
source§

#### fn black(&self) -> Painted<&T>

Returns `self` with the `fg()` set to `Color::Black`.

##### §Example
``println!("{}", value.black());``
source§

#### fn red(&self) -> Painted<&T>

Returns `self` with the `fg()` set to `Color::Red`.

##### §Example
``println!("{}", value.red());``
source§

#### fn green(&self) -> Painted<&T>

Returns `self` with the `fg()` set to `Color::Green`.

##### §Example
``println!("{}", value.green());``
source§

#### fn yellow(&self) -> Painted<&T>

Returns `self` with the `fg()` set to `Color::Yellow`.

##### §Example
``println!("{}", value.yellow());``
source§

#### fn blue(&self) -> Painted<&T>

Returns `self` with the `fg()` set to `Color::Blue`.

##### §Example
``println!("{}", value.blue());``
source§

#### fn magenta(&self) -> Painted<&T>

Returns `self` with the `fg()` set to `Color::Magenta`.

##### §Example
``println!("{}", value.magenta());``
source§

#### fn cyan(&self) -> Painted<&T>

Returns `self` with the `fg()` set to `Color::Cyan`.

##### §Example
``println!("{}", value.cyan());``
source§

#### fn white(&self) -> Painted<&T>

Returns `self` with the `fg()` set to `Color::White`.

##### §Example
``println!("{}", value.white());``
source§

#### fn bright_black(&self) -> Painted<&T>

Returns `self` with the `fg()` set to `Color::BrightBlack`.

##### §Example
``println!("{}", value.bright_black());``
source§

#### fn bright_red(&self) -> Painted<&T>

Returns `self` with the `fg()` set to `Color::BrightRed`.

##### §Example
``println!("{}", value.bright_red());``
source§

#### fn bright_green(&self) -> Painted<&T>

Returns `self` with the `fg()` set to `Color::BrightGreen`.

##### §Example
``println!("{}", value.bright_green());``
source§

#### fn bright_yellow(&self) -> Painted<&T>

Returns `self` with the `fg()` set to `Color::BrightYellow`.

##### §Example
``println!("{}", value.bright_yellow());``
source§

#### fn bright_blue(&self) -> Painted<&T>

Returns `self` with the `fg()` set to `Color::BrightBlue`.

##### §Example
``println!("{}", value.bright_blue());``
source§

#### fn bright_magenta(&self) -> Painted<&T>

Returns `self` with the `fg()` set to `Color::BrightMagenta`.

##### §Example
``println!("{}", value.bright_magenta());``
source§

#### fn bright_cyan(&self) -> Painted<&T>

Returns `self` with the `fg()` set to `Color::BrightCyan`.

##### §Example
``println!("{}", value.bright_cyan());``
source§

#### fn bright_white(&self) -> Painted<&T>

Returns `self` with the `fg()` set to `Color::BrightWhite`.

##### §Example
``println!("{}", value.bright_white());``
source§

#### fn bg(&self, value: Color) -> Painted<&T>

Returns a styled value derived from `self` with the background set to `value`.

This method should be used rarely. Instead, prefer to use color-specific builder methods like `on_red()` and `on_green()`, which have the same functionality but are pithier.

##### §Example

Set background color to red using `fg()`:

``````use yansi::{Paint, Color};

painted.bg(Color::Red);``````

Set background color to red using `on_red()`.

``````use yansi::Paint;

painted.on_red();``````
source§

#### fn on_primary(&self) -> Painted<&T>

Returns `self` with the `bg()` set to `Color::Primary`.

##### §Example
``println!("{}", value.on_primary());``
source§

#### fn on_fixed(&self, color: u8) -> Painted<&T>

Returns `self` with the `bg()` set to `Color::Fixed`.

##### §Example
``println!("{}", value.on_fixed(color));``
source§

#### fn on_rgb(&self, r: u8, g: u8, b: u8) -> Painted<&T>

Returns `self` with the `bg()` set to `Color::Rgb`.

##### §Example
``println!("{}", value.on_rgb(r, g, b));``
source§

#### fn on_black(&self) -> Painted<&T>

Returns `self` with the `bg()` set to `Color::Black`.

##### §Example
``println!("{}", value.on_black());``
source§

#### fn on_red(&self) -> Painted<&T>

Returns `self` with the `bg()` set to `Color::Red`.

##### §Example
``println!("{}", value.on_red());``
source§

#### fn on_green(&self) -> Painted<&T>

Returns `self` with the `bg()` set to `Color::Green`.

##### §Example
``println!("{}", value.on_green());``
source§

#### fn on_yellow(&self) -> Painted<&T>

Returns `self` with the `bg()` set to `Color::Yellow`.

##### §Example
``println!("{}", value.on_yellow());``
source§

#### fn on_blue(&self) -> Painted<&T>

Returns `self` with the `bg()` set to `Color::Blue`.

##### §Example
``println!("{}", value.on_blue());``
source§

#### fn on_magenta(&self) -> Painted<&T>

Returns `self` with the `bg()` set to `Color::Magenta`.

##### §Example
``println!("{}", value.on_magenta());``
source§

#### fn on_cyan(&self) -> Painted<&T>

Returns `self` with the `bg()` set to `Color::Cyan`.

##### §Example
``println!("{}", value.on_cyan());``
source§

#### fn on_white(&self) -> Painted<&T>

Returns `self` with the `bg()` set to `Color::White`.

##### §Example
``println!("{}", value.on_white());``
source§

#### fn on_bright_black(&self) -> Painted<&T>

Returns `self` with the `bg()` set to `Color::BrightBlack`.

##### §Example
``println!("{}", value.on_bright_black());``
source§

#### fn on_bright_red(&self) -> Painted<&T>

Returns `self` with the `bg()` set to `Color::BrightRed`.

##### §Example
``println!("{}", value.on_bright_red());``
source§

#### fn on_bright_green(&self) -> Painted<&T>

Returns `self` with the `bg()` set to `Color::BrightGreen`.

##### §Example
``println!("{}", value.on_bright_green());``
source§

#### fn on_bright_yellow(&self) -> Painted<&T>

Returns `self` with the `bg()` set to `Color::BrightYellow`.

##### §Example
``println!("{}", value.on_bright_yellow());``
source§

#### fn on_bright_blue(&self) -> Painted<&T>

Returns `self` with the `bg()` set to `Color::BrightBlue`.

##### §Example
``println!("{}", value.on_bright_blue());``
source§

#### fn on_bright_magenta(&self) -> Painted<&T>

Returns `self` with the `bg()` set to `Color::BrightMagenta`.

##### §Example
``println!("{}", value.on_bright_magenta());``
source§

#### fn on_bright_cyan(&self) -> Painted<&T>

Returns `self` with the `bg()` set to `Color::BrightCyan`.

##### §Example
``println!("{}", value.on_bright_cyan());``
source§

#### fn on_bright_white(&self) -> Painted<&T>

Returns `self` with the `bg()` set to `Color::BrightWhite`.

##### §Example
``println!("{}", value.on_bright_white());``
source§

#### fn attr(&self, value: Attribute) -> Painted<&T>

Enables the styling `Attribute` `value`.

This method should be used rarely. Instead, prefer to use attribute-specific builder methods like `bold()` and `underline()`, which have the same functionality but are pithier.

##### §Example

Make text bold using `attr()`:

``````use yansi::{Paint, Attribute};

painted.attr(Attribute::Bold);``````

Make text bold using using `bold()`.

``````use yansi::Paint;

painted.bold();``````
source§

#### fn bold(&self) -> Painted<&T>

Returns `self` with the `attr()` set to `Attribute::Bold`.

##### §Example
``println!("{}", value.bold());``
source§

#### fn dim(&self) -> Painted<&T>

Returns `self` with the `attr()` set to `Attribute::Dim`.

##### §Example
``println!("{}", value.dim());``
source§

#### fn italic(&self) -> Painted<&T>

Returns `self` with the `attr()` set to `Attribute::Italic`.

##### §Example
``println!("{}", value.italic());``
source§

#### fn underline(&self) -> Painted<&T>

Returns `self` with the `attr()` set to `Attribute::Underline`.

##### §Example
``println!("{}", value.underline());``

Returns `self` with the `attr()` set to `Attribute::Blink`.

##### §Example
``println!("{}", value.blink());``

Returns `self` with the `attr()` set to `Attribute::RapidBlink`.

##### §Example
``println!("{}", value.rapid_blink());``
source§

#### fn invert(&self) -> Painted<&T>

Returns `self` with the `attr()` set to `Attribute::Invert`.

##### §Example
``println!("{}", value.invert());``
source§

#### fn conceal(&self) -> Painted<&T>

Returns `self` with the `attr()` set to `Attribute::Conceal`.

##### §Example
``println!("{}", value.conceal());``
source§

#### fn strike(&self) -> Painted<&T>

Returns `self` with the `attr()` set to `Attribute::Strike`.

##### §Example
``println!("{}", value.strike());``
source§

#### fn quirk(&self, value: Quirk) -> Painted<&T>

Enables the `yansi` `Quirk` `value`.

This method should be used rarely. Instead, prefer to use quirk-specific builder methods like `mask()` and `wrap()`, which have the same functionality but are pithier.

##### §Example

Enable wrapping using `.quirk()`:

``````use yansi::{Paint, Quirk};

painted.quirk(Quirk::Wrap);``````

Enable wrapping using `wrap()`.

``````use yansi::Paint;

painted.wrap();``````
source§

Returns `self` with the `quirk()` set to `Quirk::Mask`.

##### §Example
``println!("{}", value.mask());``
source§

#### fn wrap(&self) -> Painted<&T>

Returns `self` with the `quirk()` set to `Quirk::Wrap`.

##### §Example
``println!("{}", value.wrap());``
source§

#### fn linger(&self) -> Painted<&T>

Returns `self` with the `quirk()` set to `Quirk::Linger`.

##### §Example
``println!("{}", value.linger());``
source§

#### fn clear(&self) -> Painted<&T>

👎Deprecated since 1.0.1: renamed to `resetting()` due to conflicts with `Vec::clear()`. The `clear()` method will be removed in a future release.

Returns `self` with the `quirk()` set to `Quirk::Clear`.

##### §Example
``println!("{}", value.clear());``
source§

#### fn resetting(&self) -> Painted<&T>

Returns `self` with the `quirk()` set to `Quirk::Resetting`.

##### §Example
``println!("{}", value.resetting());``
source§

#### fn bright(&self) -> Painted<&T>

Returns `self` with the `quirk()` set to `Quirk::Bright`.

##### §Example
``println!("{}", value.bright());``
source§

#### fn on_bright(&self) -> Painted<&T>

Returns `self` with the `quirk()` set to `Quirk::OnBright`.

##### §Example
``println!("{}", value.on_bright());``
source§

#### fn whenever(&self, value: Condition) -> Painted<&T>

Conditionally enable styling based on whether the `Condition` `value` applies. Replaces any previous condition.

See the crate level docs for more details.

##### §Example

Enable styling `painted` only when both `stdout` and `stderr` are TTYs:

``````use yansi::{Paint, Condition};

painted.red().on_yellow().whenever(Condition::STDOUTERR_ARE_TTY);``````
source§

source§

#### fn paint<S>(&self, style: S) -> Painted<&Self>where S: Into<Style>,

Apply a style wholesale to `self`. Any previous style is replaced. Read more
source§

### impl<T> Pointee for T

§

The type for metadata in pointers and references to `Self`.
source§

### impl<T> Same for T

§

#### type Output = T

Should always be `Self`
source§

### impl<Borrowed> SampleBorrow<Borrowed> for Borrowedwhere Borrowed: SampleUniform,

source§

#### fn borrow(&self) -> &Borrowed

Immutably borrows from an owned value. See `Borrow::borrow`
source§

### impl<T, S> SerializeUnsized<S> for Twhere T: Serialize<S>, S: Serializer + ?Sized,

source§

#### fn serialize_unsized( &self, serializer: &mut S ) -> Result<usize, <S as Fallible>::Error>

Writes the object and returns the position of the archived type.
source§

#### fn serialize_metadata(&self, _: &mut S) -> Result<(), <S as Fallible>::Error>

Serializes the metadata for the given type.
source§

### impl<T, ST, DB> StaticallySizedRow<ST, DB> for Twhere ST: SqlTypeOrSelectable + TupleSize, T: Queryable<ST, DB>, DB: Backend,

source§

#### const FIELD_COUNT: usize = <ST as crate::util::TupleSize>::SIZE

The number of fields that this type will consume.
source§

### impl<T> ToOwned for Twhere T: Clone,

§

#### 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 Twhere T: Display + ?Sized,

source§

#### default fn to_string(&self) -> String

Converts the given value to a `String`. Read more
source§

### impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

#### 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 Twhere U: TryFrom<T>,

§

#### 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§

source§

source§

### impl<T> WithSubscriber for T

source§

#### fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>where S: Into<Dispatch>,

Attaches the provided `Subscriber` to this type, returning a `WithDispatch` wrapper. Read more
source§

#### fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default `Subscriber` to this type, returning a `WithDispatch` wrapper. Read more
source§

source§

source§

source§

source§

source§

source§

source§

source§