Struct sqlx::types::Decimal [−]
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
impl Decimal
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 them
portion of the decimal numberscale
- A u32 representing thee
portion of the decimal number.
Example
use rust_decimal::Decimal; let pi = Decimal::new(3141, 3); assert_eq!(pi.to_string(), "3.141");
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 them
portion of the decimal numberscale
- A u32 representing thee
portion of the decimal number.
Example
use rust_decimal::Decimal; let pi = Decimal::from_i128_with_scale(3141i128, 3); assert_eq!(pi.to_string(), "3.141");
pub const fn from_parts(
lo: u32,
mid: u32,
hi: u32,
negative: bool,
scale: u32
) -> Decimal
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.
Example
use rust_decimal::Decimal; let pi = Decimal::from_parts(1102470952, 185874565, 1703060790, false, 28); assert_eq!(pi.to_string(), "3.1415926535897932384626433832");
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 theDecimal
.
Example
use rust_decimal::Decimal; let value = Decimal::from_scientific("9.7e-7").unwrap(); assert_eq!(value.to_string(), "0.00000097");
pub const fn scale(&self) -> u32
Returns the scale of the decimal number, otherwise known as e
.
Example
use rust_decimal::Decimal; let num = Decimal::new(1234, 3); assert_eq!(num.scale(), 3u32);
pub fn set_sign(&mut self, positive: bool)
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
use rust_decimal::Decimal; let mut one = Decimal::new(1, 0); one.set_sign(false); assert_eq!(one.to_string(), "-1");
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
use rust_decimal::Decimal; let mut one = Decimal::new(1, 0); one.set_sign_positive(false); assert_eq!(one.to_string(), "-1");
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
use rust_decimal::Decimal; let mut one = Decimal::new(1, 0); one.set_sign_negative(true); assert_eq!(one.to_string(), "-1");
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
use rust_decimal::Decimal; let mut one = Decimal::new(1, 0); one.set_scale(5); assert_eq!(one.to_string(), "0.00001");
pub fn rescale(&mut self, scale: u32)
Modifies the Decimal
to the given scale, attempting to do so without changing the
underlying number itself.
Note that setting the scale to something less then the current Decimal
s scale will
cause the newly created Decimal
to have some rounding.
Scales greater than the maximum precision supported by Decimal
will be automatically
rounded to Decimal::MAX_PRECISION
.
Rounding leverages the half up strategy.
Arguments
scale
: The scale to use for the newDecimal
number.
Example
use rust_decimal::Decimal; let mut number = Decimal::new(1_123, 3); number.rescale(6); assert_eq!(number, Decimal::new(1_123_000, 6)); let mut round = Decimal::new(145, 2); round.rescale(1); assert_eq!(round, Decimal::new(15, 1));
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
pub const 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 followign 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
pub fn is_negative(&self) -> bool
please use is_sign_negative
instead
Returns true
if the decimal is negative.
pub fn is_positive(&self) -> bool
please use is_sign_positive
instead
Returns true
if the decimal is positive.
pub const fn is_sign_negative(&self) -> bool
Returns true
if the sign bit of the decimal is negative.
pub const fn is_sign_positive(&self) -> bool
Returns true
if the sign bit of the decimal is positive.
pub const fn min_value() -> Decimal
Returns the minimum possible number that Decimal
can represent.
pub const fn max_value() -> Decimal
Returns the maximum possible number that Decimal
can represent.
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
use rust_decimal::Decimal; let pi = Decimal::new(3141, 3); let trunc = Decimal::new(3, 0); // note that it returns a decimal assert_eq!(pi.trunc(), trunc);
pub fn fract(&self) -> Decimal
Returns a new Decimal
representing the fractional portion of the number.
Example
use rust_decimal::Decimal; let pi = Decimal::new(3141, 3); let fract = Decimal::new(141, 3); // note that it returns a decimal assert_eq!(pi.fract(), fract);
pub fn abs(&self) -> Decimal
Computes the absolute value of self
.
Example
use rust_decimal::Decimal; let num = Decimal::new(-3141, 3); assert_eq!(num.abs().to_string(), "3.141");
pub fn floor(&self) -> Decimal
Returns the largest integer less than or equal to a number.
Example
use rust_decimal::Decimal; let num = Decimal::new(3641, 3); assert_eq!(num.floor().to_string(), "3");
pub fn ceil(&self) -> Decimal
Returns the smallest integer greater than or equal to a number.
Example
use rust_decimal::Decimal; 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");
pub fn max(self, other: Decimal) -> Decimal
Returns the maximum of the two numbers.
use rust_decimal::Decimal; let x = Decimal::new(1, 0); let y = Decimal::new(2, 0); assert_eq!(y, x.max(y));
pub fn min(self, other: Decimal) -> Decimal
Returns the minimum of the two numbers.
use rust_decimal::Decimal; let x = Decimal::new(1, 0); let y = Decimal::new(2, 0); assert_eq!(x, x.min(y));
pub fn normalize(&self) -> Decimal
Strips any trailing zero's from a Decimal
and converts -0 to 0.
Example
use rust_decimal::Decimal; let number = Decimal::new(3100, 3); // note that it returns a decimal, without the extra scale assert_eq!(number.normalize().to_string(), "3.1");
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
use rust_decimal::Decimal; // 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");
pub fn round_dp_with_strategy(
&self,
dp: u32,
strategy: RoundingStrategy
) -> Decimal
&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
use rust_decimal::{Decimal, RoundingStrategy}; use core::str::FromStr; let tax = Decimal::from_str("3.4395").unwrap(); assert_eq!(tax.round_dp_with_strategy(2, RoundingStrategy::RoundHalfUp).to_string(), "3.44");
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
use rust_decimal::Decimal; use core::str::FromStr; let pi = Decimal::from_str("3.1415926535897932384626433832").unwrap(); assert_eq!(pi.round_dp(2).to_string(), "3.14");
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::Decimal; use core::str::FromStr; let pi = Decimal::from_str("3.1415926535897932384626433832").unwrap(); assert_eq!(format!("{:?}", pi), "3.1415926535897932384626433832"); assert_eq!(format!("{:?}", pi.unpack()), "UnpackedDecimal { \ is_negative: false, scale: 28, hi: 1703060790, mid: 185874565, lo: 1102470952 \ }");
pub fn checked_add(self, other: Decimal) -> Option<Decimal>
Checked addition. Computes self + other
, returning None
if overflow occurred.
pub fn checked_sub(self, other: Decimal) -> Option<Decimal>
Checked subtraction. Computes self - other
, returning None
if overflow occurred.
pub fn checked_mul(self, other: Decimal) -> Option<Decimal>
Checked multiplication. Computes self * other
, returning None
if overflow occurred.
pub fn checked_div(self, other: Decimal) -> Option<Decimal>
Checked division. Computes self / other
, returning None
if other == 0.0
or the
division results in overflow.
pub fn checked_rem(self, other: Decimal) -> Option<Decimal>
Checked remainder. Computes self % other
, returning None
if other == 0.0
.
pub fn exp(&self) -> Decimal
The estimated exponential function, ex, rounded to 8 decimal places. Stops calculating when it is within tolerance is roughly 0.000002 in order to prevent multiplication overflow.
pub fn exp_with_tolerance(&self, tolerance: Decimal) -> Decimal
The estimated exponential function, ex, rounded to 8 decimal places. Stops
calculating when it is within tolerance
.
Multiplication overflows are likely if you are not careful with the size of tolerance
.
It is recommended to set the tolerance
larger for larger numbers and smaller for smaller
numbers to avoid multiplication overflow.
pub fn powi(&self, exp: u64) -> Decimal
Raise self to the given unsigned integer exponent: xy
pub fn sqrt(&self) -> Option<Decimal>
The square root of a Decimal. Uses a standard Babylonian method.
pub fn ln(&self) -> Decimal
The natural logarithm for a Decimal. Uses a fast estimation algorithm This is more accurate on larger numbers and less on numbers less than 1.
pub fn erf(&self) -> Decimal
Abramowitz Approximation of Error Function from wikipedia
pub fn norm_cdf(&self) -> Decimal
The Cumulative distribution function for a Normal distribution
pub fn norm_pdf(&self) -> Decimal
The Probability density function for a Normal distribution
pub fn from_str_radix(str: &str, radix: u32) -> Result<Decimal, Error>
Trait Implementations
impl<'a> Add<&'a Decimal> for Decimal
type Output = Decimal
The resulting type after applying the +
operator.
pub fn add(self, other: &Decimal) -> Decimal
impl<'a, 'b> Add<&'b Decimal> for &'a Decimal
type Output = Decimal
The resulting type after applying the +
operator.
pub fn add(self, other: &Decimal) -> Decimal
impl<'a> Add<Decimal> for &'a Decimal
type Output = Decimal
The resulting type after applying the +
operator.
pub fn add(self, other: Decimal) -> Decimal
impl Add<Decimal> for Decimal
type Output = Decimal
The resulting type after applying the +
operator.
pub fn add(self, other: Decimal) -> Decimal
impl<'a> AddAssign<&'a Decimal> for &'a mut Decimal
pub fn add_assign(&mut self, other: &'a Decimal)
impl<'a> AddAssign<&'a Decimal> for Decimal
pub fn add_assign(&mut self, other: &'a Decimal)
impl AddAssign<Decimal> for Decimal
pub fn add_assign(&mut self, other: Decimal)
impl<'a> AddAssign<Decimal> for &'a mut Decimal
pub fn add_assign(&mut self, other: Decimal)
impl Clone for Decimal
pub fn clone(&self) -> Decimal
pub fn clone_from(&mut self, source: &Self)
1.0.0[src]
impl Copy for Decimal
impl Debug for Decimal
impl<'_> Decode<'_, MySql> for Decimal
[src]
pub fn decode(
value: MySqlValueRef<'_>
) -> Result<Decimal, Box<dyn Error + 'static + Send + Sync, Global>>
[src]
value: MySqlValueRef<'_>
) -> Result<Decimal, Box<dyn Error + 'static + Send + Sync, Global>>
impl<'_> Decode<'_, Postgres> for Decimal
[src]
pub fn decode(
value: PgValueRef<'_>
) -> Result<Decimal, Box<dyn Error + 'static + Send + Sync, Global>>
[src]
value: PgValueRef<'_>
) -> Result<Decimal, Box<dyn Error + 'static + Send + Sync, Global>>
impl Default for Decimal
impl<'de> Deserialize<'de> for Decimal
pub fn deserialize<D>(
deserializer: D
) -> Result<Decimal, <D as Deserializer<'de>>::Error> where
D: Deserializer<'de>,
deserializer: D
) -> Result<Decimal, <D as Deserializer<'de>>::Error> where
D: Deserializer<'de>,
impl Display for Decimal
impl<'a> Div<&'a Decimal> for Decimal
type Output = Decimal
The resulting type after applying the /
operator.
pub fn div(self, other: &Decimal) -> Decimal
impl<'a, 'b> Div<&'b Decimal> for &'a Decimal
type Output = Decimal
The resulting type after applying the /
operator.
pub fn div(self, other: &Decimal) -> Decimal
impl<'a> Div<Decimal> for &'a Decimal
type Output = Decimal
The resulting type after applying the /
operator.
pub fn div(self, other: Decimal) -> Decimal
impl Div<Decimal> for Decimal
type Output = Decimal
The resulting type after applying the /
operator.
pub fn div(self, other: Decimal) -> Decimal
impl<'a> DivAssign<&'a Decimal> for &'a mut Decimal
pub fn div_assign(&mut self, other: &'a Decimal)
impl<'a> DivAssign<&'a Decimal> for Decimal
pub fn div_assign(&mut self, other: &'a Decimal)
impl<'a> DivAssign<Decimal> for &'a mut Decimal
pub fn div_assign(&mut self, other: Decimal)
impl DivAssign<Decimal> for Decimal
pub fn div_assign(&mut self, other: Decimal)
impl<'_> Encode<'_, MySql> for Decimal
[src]
pub fn encode_by_ref(&self, buf: &mut Vec<u8, Global>) -> IsNull
[src]
#[must_use]pub fn encode(
self,
buf: &mut <DB as HasArguments<'q>>::ArgumentBuffer
) -> IsNull
[src]
self,
buf: &mut <DB as HasArguments<'q>>::ArgumentBuffer
) -> IsNull
pub fn produces(&self) -> Option<<DB as Database>::TypeInfo>
[src]
pub fn size_hint(&self) -> usize
[src]
impl<'_> Encode<'_, Postgres> for Decimal
[src]
Panics
If this Decimal
cannot be represented by PgNumeric
.
pub fn encode_by_ref(&self, buf: &mut PgArgumentBuffer) -> IsNull
[src]
#[must_use]pub fn encode(
self,
buf: &mut <DB as HasArguments<'q>>::ArgumentBuffer
) -> IsNull
[src]
self,
buf: &mut <DB as HasArguments<'q>>::ArgumentBuffer
) -> IsNull
pub fn produces(&self) -> Option<<DB as Database>::TypeInfo>
[src]
pub fn size_hint(&self) -> usize
[src]
impl Eq for Decimal
impl From<i16> for Decimal
impl From<i32> for Decimal
impl From<i64> for Decimal
impl From<i8> for Decimal
impl From<isize> for Decimal
impl From<u16> for Decimal
impl From<u32> for Decimal
impl From<u64> for Decimal
impl From<u8> for Decimal
impl From<usize> for Decimal
impl FromPrimitive for Decimal
pub fn from_i32(n: i32) -> Option<Decimal>
pub fn from_i64(n: i64) -> Option<Decimal>
pub fn from_u32(n: u32) -> Option<Decimal>
pub fn from_u64(n: u64) -> Option<Decimal>
pub fn from_f32(n: f32) -> Option<Decimal>
pub fn from_f64(n: f64) -> Option<Decimal>
pub fn from_isize(n: isize) -> Option<Self>
[src]
pub fn from_i8(n: i8) -> Option<Self>
[src]
pub fn from_i16(n: i16) -> Option<Self>
[src]
pub fn from_i128(n: i128) -> Option<Self>
[src]
pub fn from_usize(n: usize) -> Option<Self>
[src]
pub fn from_u8(n: u8) -> Option<Self>
[src]
pub fn from_u16(n: u16) -> Option<Self>
[src]
pub fn from_u128(n: u128) -> Option<Self>
[src]
impl FromStr for Decimal
type Err = Error
The associated error which can be returned from parsing.
pub fn from_str(value: &str) -> Result<Decimal, <Decimal as FromStr>::Err>
impl Hash for Decimal
pub fn hash<H>(&self, state: &mut H) where
H: Hasher,
H: Hasher,
pub fn hash_slice<H>(data: &[Self], state: &mut H) where
H: Hasher,
1.3.0[src]
H: Hasher,
impl LowerExp for Decimal
impl<'a> Mul<&'a Decimal> for Decimal
type Output = Decimal
The resulting type after applying the *
operator.
pub fn mul(self, other: &Decimal) -> Decimal
impl<'a, 'b> Mul<&'b Decimal> for &'a Decimal
type Output = Decimal
The resulting type after applying the *
operator.
pub fn mul(self, other: &Decimal) -> Decimal
impl Mul<Decimal> for Decimal
type Output = Decimal
The resulting type after applying the *
operator.
pub fn mul(self, other: Decimal) -> Decimal
impl<'a> Mul<Decimal> for &'a Decimal
type Output = Decimal
The resulting type after applying the *
operator.
pub fn mul(self, other: Decimal) -> Decimal
impl<'a> MulAssign<&'a Decimal> for &'a mut Decimal
pub fn mul_assign(&mut self, other: &'a Decimal)
impl<'a> MulAssign<&'a Decimal> for Decimal
pub fn mul_assign(&mut self, other: &'a Decimal)
impl<'a> MulAssign<Decimal> for &'a mut Decimal
pub fn mul_assign(&mut self, other: Decimal)
impl MulAssign<Decimal> for Decimal
pub fn mul_assign(&mut self, other: Decimal)
impl<'a> Neg for &'a Decimal
impl Neg for Decimal
impl Num for Decimal
type FromStrRadixErr = Error
pub fn from_str_radix(
str: &str,
radix: u32
) -> Result<Decimal, <Decimal as Num>::FromStrRadixErr>
str: &str,
radix: u32
) -> Result<Decimal, <Decimal as Num>::FromStrRadixErr>
impl One for Decimal
pub fn one() -> Decimal
pub fn set_one(&mut self)
[src]
pub fn is_one(&self) -> bool where
Self: PartialEq<Self>,
[src]
Self: PartialEq<Self>,
impl Ord for Decimal
pub fn cmp(&self, other: &Decimal) -> Ordering
#[must_use]pub fn max(self, other: Self) -> Self
1.21.0[src]
#[must_use]pub fn min(self, other: Self) -> Self
1.21.0[src]
#[must_use]pub fn clamp(self, min: Self, max: Self) -> Self
1.50.0[src]
impl PartialEq<Decimal> for Decimal
impl PartialOrd<Decimal> for Decimal
pub fn partial_cmp(&self, other: &Decimal) -> Option<Ordering>
#[must_use]pub fn lt(&self, other: &Rhs) -> bool
1.0.0[src]
#[must_use]pub fn le(&self, other: &Rhs) -> bool
1.0.0[src]
#[must_use]pub fn gt(&self, other: &Rhs) -> bool
1.0.0[src]
#[must_use]pub fn ge(&self, other: &Rhs) -> bool
1.0.0[src]
impl<'a> Rem<&'a Decimal> for Decimal
type Output = Decimal
The resulting type after applying the %
operator.
pub fn rem(self, other: &Decimal) -> Decimal
impl<'a, 'b> Rem<&'b Decimal> for &'a Decimal
type Output = Decimal
The resulting type after applying the %
operator.
pub fn rem(self, other: &Decimal) -> Decimal
impl<'a> Rem<Decimal> for &'a Decimal
type Output = Decimal
The resulting type after applying the %
operator.
pub fn rem(self, other: Decimal) -> Decimal
impl Rem<Decimal> for Decimal
type Output = Decimal
The resulting type after applying the %
operator.
pub fn rem(self, other: Decimal) -> Decimal
impl<'a> RemAssign<&'a Decimal> for &'a mut Decimal
pub fn rem_assign(&mut self, other: &'a Decimal)
impl<'a> RemAssign<&'a Decimal> for Decimal
pub fn rem_assign(&mut self, other: &'a Decimal)
impl<'a> RemAssign<Decimal> for &'a mut Decimal
pub fn rem_assign(&mut self, other: Decimal)
impl RemAssign<Decimal> for Decimal
pub fn rem_assign(&mut self, other: Decimal)
impl Serialize for Decimal
pub fn serialize<S>(
&self,
serializer: S
) -> Result<<S as Serializer>::Ok, <S as Serializer>::Error> where
S: Serializer,
&self,
serializer: S
) -> Result<<S as Serializer>::Ok, <S as Serializer>::Error> where
S: Serializer,
impl Signed for Decimal
pub fn abs(&self) -> Decimal
pub fn abs_sub(&self, other: &Decimal) -> Decimal
pub fn signum(&self) -> Decimal
pub fn is_positive(&self) -> bool
pub fn is_negative(&self) -> bool
impl<'a> Sub<&'a Decimal> for Decimal
type Output = Decimal
The resulting type after applying the -
operator.
pub fn sub(self, other: &Decimal) -> Decimal
impl<'a, 'b> Sub<&'b Decimal> for &'a Decimal
type Output = Decimal
The resulting type after applying the -
operator.
pub fn sub(self, other: &Decimal) -> Decimal
impl<'a> Sub<Decimal> for &'a Decimal
type Output = Decimal
The resulting type after applying the -
operator.
pub fn sub(self, other: Decimal) -> Decimal
impl Sub<Decimal> for Decimal
type Output = Decimal
The resulting type after applying the -
operator.
pub fn sub(self, other: Decimal) -> Decimal
impl<'a> SubAssign<&'a Decimal> for Decimal
pub fn sub_assign(&mut self, other: &'a Decimal)
impl<'a> SubAssign<&'a Decimal> for &'a mut Decimal
pub fn sub_assign(&mut self, other: &'a Decimal)
impl<'a> SubAssign<Decimal> for &'a mut Decimal
pub fn sub_assign(&mut self, other: Decimal)
impl SubAssign<Decimal> for Decimal
pub fn sub_assign(&mut self, other: Decimal)
impl<'a> Sum<&'a Decimal> for Decimal
impl Sum<Decimal> for Decimal
impl ToPrimitive for Decimal
pub fn to_i64(&self) -> Option<i64>
pub fn to_i128(&self) -> Option<i128>
pub fn to_u64(&self) -> Option<u64>
pub fn to_u128(&self) -> Option<u128>
pub fn to_f64(&self) -> Option<f64>
pub fn to_isize(&self) -> Option<isize>
[src]
pub fn to_i8(&self) -> Option<i8>
[src]
pub fn to_i16(&self) -> Option<i16>
[src]
pub fn to_i32(&self) -> Option<i32>
[src]
pub fn to_usize(&self) -> Option<usize>
[src]
pub fn to_u8(&self) -> Option<u8>
[src]
pub fn to_u16(&self) -> Option<u16>
[src]
pub fn to_u32(&self) -> Option<u32>
[src]
pub fn to_f32(&self) -> Option<f32>
[src]
impl TryFrom<PgNumeric> for Decimal
[src]
type Error = Box<dyn Error + 'static + Send + Sync, Global>
The type returned in the event of a conversion error.
pub fn try_from(
numeric: PgNumeric
) -> Result<Decimal, Box<dyn Error + 'static + Send + Sync, Global>>
[src]
numeric: PgNumeric
) -> Result<Decimal, Box<dyn Error + 'static + Send + Sync, Global>>
impl TryFrom<f32> for Decimal
type Error = Error
The type returned in the event of a conversion error.
pub fn try_from(value: f32) -> Result<Decimal, Error>
impl TryFrom<f64> for Decimal
type Error = Error
The type returned in the event of a conversion error.
pub fn try_from(value: f64) -> Result<Decimal, Error>
impl Type<MySql> for Decimal
[src]
pub fn type_info() -> MySqlTypeInfo
[src]
pub fn compatible(ty: &<DB as Database>::TypeInfo) -> bool
[src]
impl Type<Postgres> for Decimal
[src]
pub fn type_info() -> PgTypeInfo
[src]
pub fn compatible(ty: &<DB as Database>::TypeInfo) -> bool
[src]
impl UpperExp for Decimal
impl Zero for Decimal
Auto Trait Implementations
impl RefUnwindSafe for Decimal
[src]
impl Send for Decimal
[src]
impl Sync for Decimal
[src]
impl Unpin for Decimal
[src]
impl UnwindSafe for Decimal
[src]
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> CallHasher for T where
T: Hash,
T: Hash,
impl<T> CallHasher for T where
T: Hash + ?Sized,
T: Hash + ?Sized,
impl<T> Conv for T
impl<T> Conv for T
impl<T> DeserializeOwned for T where
T: for<'de> Deserialize<'de>,
[src]
T: for<'de> Deserialize<'de>,
impl<Q, K> Equivalent<K> for Q where
K: Borrow<Q> + ?Sized,
Q: Eq + ?Sized,
[src]
K: Borrow<Q> + ?Sized,
Q: Eq + ?Sized,
pub fn equivalent(&self, key: &K) -> bool
[src]
impl<T> FmtForward for T
pub fn fmt_binary(self) -> FmtBinary<Self> where
Self: Binary,
Self: Binary,
pub fn fmt_display(self) -> FmtDisplay<Self> where
Self: Display,
Self: Display,
pub fn fmt_lower_exp(self) -> FmtLowerExp<Self> where
Self: LowerExp,
Self: LowerExp,
pub fn fmt_lower_hex(self) -> FmtLowerHex<Self> where
Self: LowerHex,
Self: LowerHex,
pub fn fmt_octal(self) -> FmtOctal<Self> where
Self: Octal,
Self: Octal,
pub fn fmt_pointer(self) -> FmtPointer<Self> where
Self: Pointer,
Self: Pointer,
pub fn fmt_upper_exp(self) -> FmtUpperExp<Self> where
Self: UpperExp,
Self: UpperExp,
pub fn fmt_upper_hex(self) -> FmtUpperHex<Self> where
Self: UpperHex,
Self: UpperHex,
impl<T> From<T> for T
[src]
impl<I> FromRadix10 for I where
I: Zero + One + AddAssign<I> + MulAssign<I>,
I: Zero + One + AddAssign<I> + MulAssign<I>,
impl<I> FromRadix10Signed for I where
I: Zero + One + AddAssign<I> + SubAssign<I> + MulAssign<I>,
I: Zero + One + AddAssign<I> + SubAssign<I> + MulAssign<I>,
impl<I> FromRadix16 for I where
I: Zero + One + AddAssign<I> + MulAssign<I>,
I: Zero + One + AddAssign<I> + MulAssign<I>,
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> NumAssign for T where
T: Num + NumAssignOps<T>,
[src]
T: Num + NumAssignOps<T>,
impl<T, Rhs> NumAssignOps<Rhs> for T where
T: AddAssign<Rhs> + SubAssign<Rhs> + MulAssign<Rhs> + DivAssign<Rhs> + RemAssign<Rhs>,
[src]
T: AddAssign<Rhs> + SubAssign<Rhs> + MulAssign<Rhs> + DivAssign<Rhs> + RemAssign<Rhs>,
impl<T> NumAssignRef for T where
T: NumAssign + for<'r> NumAssignOps<&'r T>,
[src]
T: NumAssign + for<'r> NumAssignOps<&'r T>,
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>,
[src]
T: Sub<Rhs, Output = Output> + Mul<Rhs, Output = Output> + Div<Rhs, Output = Output> + Add<Rhs, Output = Output> + Rem<Rhs, Output = Output>,
impl<T> NumRef for T where
T: Num + for<'r> NumOps<&'r T, T>,
[src]
T: Num + for<'r> NumOps<&'r T, T>,
impl<T> Pipe for T where
T: ?Sized,
T: ?Sized,
pub fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> R
pub fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> R where
R: 'a,
R: 'a,
pub fn pipe_ref_mut<'a, R>(
&'a mut self,
func: impl FnOnce(&'a mut Self) -> R
) -> R where
R: 'a,
&'a mut self,
func: impl FnOnce(&'a mut Self) -> R
) -> R where
R: 'a,
pub fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R where
Self: Borrow<B>,
R: 'a,
B: 'a + ?Sized,
Self: Borrow<B>,
R: 'a,
B: 'a + ?Sized,
pub fn pipe_borrow_mut<'a, B, R>(
&'a mut self,
func: impl FnOnce(&'a mut B) -> R
) -> R where
Self: BorrowMut<B>,
R: 'a,
B: 'a + ?Sized,
&'a mut self,
func: impl FnOnce(&'a mut B) -> R
) -> R where
Self: BorrowMut<B>,
R: 'a,
B: 'a + ?Sized,
pub fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R where
Self: AsRef<U>,
U: 'a + ?Sized,
R: 'a,
Self: AsRef<U>,
U: 'a + ?Sized,
R: 'a,
pub fn pipe_as_mut<'a, U, R>(
&'a mut self,
func: impl FnOnce(&'a mut U) -> R
) -> R where
Self: AsMut<U>,
U: 'a + ?Sized,
R: 'a,
&'a mut self,
func: impl FnOnce(&'a mut U) -> R
) -> R where
Self: AsMut<U>,
U: 'a + ?Sized,
R: 'a,
pub fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R where
Self: Deref<Target = T>,
T: 'a + ?Sized,
R: 'a,
Self: Deref<Target = T>,
T: 'a + ?Sized,
R: 'a,
pub fn pipe_deref_mut<'a, T, R>(
&'a mut self,
func: impl FnOnce(&'a mut T) -> R
) -> R where
Self: DerefMut<Target = T> + Deref,
T: 'a + ?Sized,
R: 'a,
&'a mut self,
func: impl FnOnce(&'a mut T) -> R
) -> R where
Self: DerefMut<Target = T> + Deref,
T: 'a + ?Sized,
R: 'a,
impl<T> Pipe for T
impl<T> PipeAsRef for T
pub fn pipe_as_ref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R where
Self: AsRef<T>,
T: 'a,
R: 'a,
Self: AsRef<T>,
T: 'a,
R: 'a,
pub fn pipe_as_mut<'a, T, R>(
&'a mut self,
func: impl FnOnce(&'a mut T) -> R
) -> R where
Self: AsMut<T>,
T: 'a,
R: 'a,
&'a mut self,
func: impl FnOnce(&'a mut T) -> R
) -> R where
Self: AsMut<T>,
T: 'a,
R: 'a,
impl<T> PipeBorrow for T
pub fn pipe_borrow<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R where
Self: Borrow<T>,
T: 'a,
R: 'a,
Self: Borrow<T>,
T: 'a,
R: 'a,
pub fn pipe_borrow_mut<'a, T, R>(
&'a mut self,
func: impl FnOnce(&'a mut T) -> R
) -> R where
Self: BorrowMut<T>,
T: 'a,
R: 'a,
&'a mut self,
func: impl FnOnce(&'a mut T) -> R
) -> R where
Self: BorrowMut<T>,
T: 'a,
R: 'a,
impl<T> PipeDeref for T
pub fn pipe_deref<'a, R>(
&'a self,
func: impl FnOnce(&'a Self::Target) -> R
) -> R where
Self: Deref,
R: 'a,
&'a self,
func: impl FnOnce(&'a Self::Target) -> R
) -> R where
Self: Deref,
R: 'a,
pub fn pipe_deref_mut<'a, R>(
&'a mut self,
func: impl FnOnce(&'a mut Self::Target) -> R
) -> R where
Self: DerefMut,
R: 'a,
&'a mut self,
func: impl FnOnce(&'a mut Self::Target) -> R
) -> R where
Self: DerefMut,
R: 'a,
impl<T> PipeRef for T
pub fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> R where
R: 'a,
R: 'a,
pub fn pipe_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> R where
R: 'a,
R: 'a,
impl<T, Base> RefNum<Base> for T where
T: NumOps<Base, Base> + for<'r> NumOps<&'r Base, Base>,
[src]
T: NumOps<Base, Base> + for<'r> NumOps<&'r Base, Base>,
impl<T> Same<T> for T
type Output = T
Should always be Self
impl<T> Tap for T
pub fn tap(self, func: impl FnOnce(&Self)) -> Self
pub fn tap_mut(self, func: impl FnOnce(&mut Self)) -> Self
pub fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self where
Self: Borrow<B>,
B: ?Sized,
Self: Borrow<B>,
B: ?Sized,
pub fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self where
Self: BorrowMut<B>,
B: ?Sized,
Self: BorrowMut<B>,
B: ?Sized,
pub fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self where
Self: AsRef<R>,
R: ?Sized,
Self: AsRef<R>,
R: ?Sized,
pub fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self where
Self: AsMut<R>,
R: ?Sized,
Self: AsMut<R>,
R: ?Sized,
pub fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self where
Self: Deref<Target = T>,
T: ?Sized,
Self: Deref<Target = T>,
T: ?Sized,
pub fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self where
Self: DerefMut<Target = T> + Deref,
T: ?Sized,
Self: DerefMut<Target = T> + Deref,
T: ?Sized,
pub fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
pub fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
pub fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self where
Self: Borrow<B>,
B: ?Sized,
Self: Borrow<B>,
B: ?Sized,
pub fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self where
Self: BorrowMut<B>,
B: ?Sized,
Self: BorrowMut<B>,
B: ?Sized,
pub fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self where
Self: AsRef<R>,
R: ?Sized,
Self: AsRef<R>,
R: ?Sized,
pub fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self where
Self: AsMut<R>,
R: ?Sized,
Self: AsMut<R>,
R: ?Sized,
pub fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self where
Self: Deref<Target = T>,
T: ?Sized,
Self: Deref<Target = T>,
T: ?Sized,
pub fn tap_deref_mut_dbg<T>(self, func: impl FnOnce(&mut T)) -> Self where
Self: DerefMut<Target = T> + Deref,
T: ?Sized,
Self: DerefMut<Target = T> + Deref,
T: ?Sized,
impl<T> Tap for T
pub fn tap<F, R>(self, func: F) -> Self where
F: FnOnce(&Self) -> R,
F: FnOnce(&Self) -> R,
pub fn tap_dbg<F, R>(self, func: F) -> Self where
F: FnOnce(&Self) -> R,
F: FnOnce(&Self) -> R,
pub fn tap_mut<F, R>(self, func: F) -> Self where
F: FnOnce(&mut Self) -> R,
F: FnOnce(&mut Self) -> R,
pub fn tap_mut_dbg<F, R>(self, func: F) -> Self where
F: FnOnce(&mut Self) -> R,
F: FnOnce(&mut Self) -> R,
impl<T, U> TapAsRef<U> for T where
U: ?Sized,
U: ?Sized,
pub fn tap_ref<F, R>(self, func: F) -> Self where
Self: AsRef<T>,
F: FnOnce(&T) -> R,
Self: AsRef<T>,
F: FnOnce(&T) -> R,
pub fn tap_ref_dbg<F, R>(self, func: F) -> Self where
Self: AsRef<T>,
F: FnOnce(&T) -> R,
Self: AsRef<T>,
F: FnOnce(&T) -> R,
pub fn tap_ref_mut<F, R>(self, func: F) -> Self where
Self: AsMut<T>,
F: FnOnce(&mut T) -> R,
Self: AsMut<T>,
F: FnOnce(&mut T) -> R,
pub fn tap_ref_mut_dbg<F, R>(self, func: F) -> Self where
Self: AsMut<T>,
F: FnOnce(&mut T) -> R,
Self: AsMut<T>,
F: FnOnce(&mut T) -> R,
impl<T, U> TapBorrow<U> for T where
U: ?Sized,
U: ?Sized,
pub fn tap_borrow<F, R>(self, func: F) -> Self where
Self: Borrow<T>,
F: FnOnce(&T) -> R,
Self: Borrow<T>,
F: FnOnce(&T) -> R,
pub fn tap_borrow_dbg<F, R>(self, func: F) -> Self where
Self: Borrow<T>,
F: FnOnce(&T) -> R,
Self: Borrow<T>,
F: FnOnce(&T) -> R,
pub fn tap_borrow_mut<F, R>(self, func: F) -> Self where
Self: BorrowMut<T>,
F: FnOnce(&mut T) -> R,
Self: BorrowMut<T>,
F: FnOnce(&mut T) -> R,
pub fn tap_borrow_mut_dbg<F, R>(self, func: F) -> Self where
Self: BorrowMut<T>,
F: FnOnce(&mut T) -> R,
Self: BorrowMut<T>,
F: FnOnce(&mut T) -> R,
impl<T> TapDeref for T
pub fn tap_deref<F, R>(self, func: F) -> Self where
Self: Deref,
F: FnOnce(&Self::Target) -> R,
Self: Deref,
F: FnOnce(&Self::Target) -> R,
pub fn tap_deref_dbg<F, R>(self, func: F) -> Self where
Self: Deref,
F: FnOnce(&Self::Target) -> R,
Self: Deref,
F: FnOnce(&Self::Target) -> R,
pub fn tap_deref_mut<F, R>(self, func: F) -> Self where
Self: DerefMut,
F: FnOnce(&mut Self::Target) -> R,
Self: DerefMut,
F: FnOnce(&mut Self::Target) -> R,
pub fn tap_deref_mut_dbg<F, R>(self, func: F) -> Self where
Self: DerefMut,
F: FnOnce(&mut Self::Target) -> R,
Self: DerefMut,
F: FnOnce(&mut Self::Target) -> R,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
pub fn to_owned(&self) -> T
[src]
pub fn clone_into(&self, target: &mut T)
[src]
impl<T> ToString for T where
T: Display + ?Sized,
[src]
T: Display + ?Sized,
impl<T> TryConv for T
impl<T> TryConv for T
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
pub fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
V: MultiLane<T>,