Struct fraction::prelude::GenericDecimal

source ·
pub struct GenericDecimal<T, P>(/* private fields */)
where
    T: Clone + Integer,
    P: Copy + Integer + Into<usize>;
Expand description

Decimal type implementation

T is the type for data P is the type for precision

Uses GenericFraction internally to represent the data. Precision is being used for representation purposes only. Calculations do not use precision, but comparison does.

§Examples

use fraction::GenericDecimal;

type Decimal = GenericDecimal<u64, u8>;

let d1 = Decimal::from(12);
let d2 = Decimal::from(0.5);

let mul = d1 * d2;
let div = d1 / d2;
let add = d1 + d2;

assert_eq!(mul, 6.into());
assert_eq!(div, Decimal::from("24.00"));
assert_eq!(add, Decimal::from(12.5));

Implementations§

source§

impl<T: Clone + Integer + ToBigUint + ToBigInt + GenericInteger, P: Copy + Integer + Into<usize>> GenericDecimal<T, P>

source

pub fn sqrt_abs_with_accuracy_raw( &self, accuracy: impl Borrow<Accuracy> ) -> RawApprox

See GenericFraction::sqrt_abs_with_accuracy_raw.

source

pub fn sqrt_abs_with_accuracy( &self, accuracy: impl Borrow<Accuracy> ) -> GenericDecimal<BigUint, P>

See GenericFraction::sqrt_abs_with_accuracy.

source

pub fn sqrt_abs_raw(&self, decimal_places: u32) -> RawApprox

See GenericFraction::sqrt_abs_raw.

source

pub fn sqrt_abs(&self, decimal_places: u32) -> GenericDecimal<BigUint, P>

See GenericFraction::sqrt_abs.

source

pub fn sqrt_with_accuracy_raw( &self, accuracy: impl Borrow<Accuracy> ) -> RawApprox

See GenericFraction::sqrt_with_accuracy_raw.

source

pub fn sqrt_with_accuracy( &self, accuracy: impl Borrow<Accuracy> ) -> GenericDecimal<BigUint, P>

See GenericFraction::sqrt_with_accuracy.

source

pub fn sqrt_raw(&self, decimal_places: u32) -> RawApprox

See GenericFraction::sqrt_raw.

source

pub fn sqrt(&self, decimal_places: u32) -> GenericDecimal<BigUint, P>

See GenericFraction::sqrt.

source§

impl<T, P> GenericDecimal<T, P>

source

pub const fn sign(&self) -> Option<Sign>

Returns Some(Sign) of the decimal, or None if NaN is the value

source

pub fn set_precision(self, precision: P) -> Self

Sets representational precision for the Decimal The precision is only used for comparison and representation, not for calculations.

This is suggested method for you to utilise if you know what precision you want to work with.

§Examples
use fraction::GenericDecimal;

type D = GenericDecimal<u32, u8>;

let first = D::from("0.004")  // initial precision is 4
            .set_precision(2);  // but we want to work with 2
let second = D::from("0.006").set_precision(2);

// Even though "first" and "second" both have precision 2
// the actual calculations are still performed with their
// exact initial precision
assert_eq!(first + second, D::from("0.01"));

// The comparison, on the other hand, takes the precision into account
// so the actual compared numbers will be calculated up the highest
// precision of both operands
assert_ne!(  // compares "0.010" with "0.011"
    D::from("0.01"),  // has precision 2
    D::from("0.011")  // has precision 3
);

assert_eq!(  // compares "0.01" with "0.01"
    D::from("0.01").set_precision(2),
    D::from("0.011").set_precision(2)
);
source

pub const fn get_precision(&self) -> P

Returns the current representational precision for the Decimal

source

pub fn calc_precision(self, max_precision: Option<P>) -> Self

Try to recalculate the representational precision depending on the internal Fraction, which is the actual value.

Performs the actual division until the exact decimal value is calculated, the precision type (P) capacity is reached (e.g. 255 for u8) or max_precision is reached, if it is given.

§WARNING

You only need this method if you want to find the max available precision for the current decimal value. However, keep in mind that irrational values (such as 1/3) do not have finite precision, so if this method returns P::MAX (or max_precision), most likely you have an irrational value. Be careful with max numbers for usize - that can take very long time to compute (more than a minute)

source

pub fn nan() -> Self

source

pub fn infinity() -> Self

source

pub fn neg_infinity() -> Self

source

pub fn neg_zero() -> Self

source

pub fn min_positive_value() -> Self
where T: Bounded, P: Bounded,

source

pub const fn is_nan(&self) -> bool

source

pub const fn is_infinite(&self) -> bool

source

pub const fn is_finite(&self) -> bool

source

pub fn is_normal(&self) -> bool

source

pub fn classify(&self) -> FpCategory

source

pub fn floor(&self) -> Self

source

pub fn ceil(&self) -> Self

source

pub fn round(&self) -> Self

source

pub fn trunc(&self) -> Self

source

pub fn fract(&self) -> Self

source

pub fn abs(&self) -> Self

source

pub fn signum(&self) -> Self

source

pub const fn is_sign_positive(&self) -> bool

source

pub const fn is_sign_negative(&self) -> bool

source

pub fn mul_add(&self, a: Self, b: Self) -> Self

source

pub fn recip(&self) -> Self

source

pub fn map( self, fun: impl FnOnce(GenericFraction<T>) -> GenericFraction<T> ) -> Self

source

pub fn map_mut(&mut self, fun: impl FnOnce(&mut GenericFraction<T>))

source

pub fn map_ref( &self, fun: impl FnOnce(&GenericFraction<T>) -> GenericFraction<T> ) -> Self

source

pub fn apply_ref<R>(&self, fun: impl FnOnce(&GenericFraction<T>, P) -> R) -> R

👎Deprecated: Use match decimal {GenericDecimal(fraction, precision) => ... }
source

pub fn from_fraction(fraction: GenericFraction<T>) -> Self

Convert from a GenericFraction

Automatically calculates precision, so for “bad” numbers may take a lot of CPU cycles, especially if precision represented by big types (e.g. usize)

§Examples
use fraction::{Fraction, Decimal};

let from_fraction = Decimal::from_fraction(Fraction::new(1u64, 3u64));
let from_division = Decimal::from(1) / Decimal::from(3);

let d1 = Decimal::from(4) / from_fraction;
let d2 = Decimal::from(4) / from_division;

assert_eq!(d1, d2);
assert_eq!(d1, Decimal::from(12));

Trait Implementations§

source§

impl<'a, O, T, P> Add<O> for &'a GenericDecimal<T, P>
where T: Clone + GenericInteger, P: Copy + GenericInteger + Into<usize>, &'a T: Add<Output = T>, O: Into<GenericDecimal<T, P>>,

§

type Output = GenericDecimal<T, P>

The resulting type after applying the + operator.
source§

fn add(self, other: O) -> Self::Output

Performs the + operation. Read more
source§

impl<O, T, P> Add<O> for GenericDecimal<T, P>

§

type Output = GenericDecimal<T, P>

The resulting type after applying the + operator.
source§

fn add(self, other: O) -> Self::Output

Performs the + operation. Read more
source§

impl<'a, T, P> Add for &'a GenericDecimal<T, P>
where T: Clone + GenericInteger, P: Copy + GenericInteger + Into<usize>, &'a T: Add<Output = T>,

§

type Output = GenericDecimal<T, P>

The resulting type after applying the + operator.
source§

fn add(self, other: Self) -> Self::Output

Performs the + operation. Read more
source§

impl<'a, T, P> AddAssign<&'a GenericDecimal<T, P>> for GenericDecimal<T, P>

source§

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

Performs the += operation. Read more
source§

impl<O, T, P> AddAssign<O> for GenericDecimal<T, P>

source§

fn add_assign(&mut self, other: O)

Performs the += operation. Read more
source§

impl<T, P> Bounded for GenericDecimal<T, P>

source§

fn min_value() -> Self

Returns the smallest finite number this type can represent
source§

fn max_value() -> Self

Returns the largest finite number this type can represent
source§

impl<T, P> CheckedAdd for GenericDecimal<T, P>

source§

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

Adds two numbers, checking for overflow. If overflow happens, None is returned.
source§

impl<T, P> CheckedDiv for GenericDecimal<T, P>

source§

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

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

impl<T, P> CheckedMul for GenericDecimal<T, P>

source§

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

Multiplies two numbers, checking for underflow or overflow. If underflow or overflow happens, None is returned.
source§

impl<T, P> CheckedSub for GenericDecimal<T, P>

source§

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

Subtracts two numbers, checking for underflow. If underflow happens, None is returned.
source§

impl<T, P> Clone for GenericDecimal<T, P>
where T: Clone + Integer + Clone, P: Copy + Integer + Into<usize> + Clone,

source§

fn clone(&self) -> GenericDecimal<T, P>

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<T, P> Debug for GenericDecimal<T, P>

source§

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

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

impl<T, P> Default for GenericDecimal<T, P>
where T: Clone + Integer, P: Copy + Integer + Into<usize>,

source§

fn default() -> Self

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

impl<'de, T, P> Deserialize<'de> for GenericDecimal<T, P>
where T: Clone + Integer + Deserialize<'de>, P: Copy + Integer + Into<usize> + Deserialize<'de>,

source§

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

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

impl<T, P> Display for GenericDecimal<T, P>
where T: Clone + GenericInteger, P: Copy + Integer + Into<usize>,

source§

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

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

impl<'a, O, T, P> Div<O> for &'a GenericDecimal<T, P>
where T: Clone + GenericInteger + Div, P: Copy + GenericInteger + Into<usize>, &'a T: Div<Output = T>, O: Into<GenericDecimal<T, P>>,

§

type Output = GenericDecimal<T, P>

The resulting type after applying the / operator.
source§

fn div(self, other: O) -> Self::Output

Performs the / operation. Read more
source§

impl<O, T, P> Div<O> for GenericDecimal<T, P>
where T: Clone + GenericInteger + Div, P: Copy + GenericInteger + Into<usize>, O: Into<Self>,

§

type Output = GenericDecimal<T, P>

The resulting type after applying the / operator.
source§

fn div(self, other: O) -> Self::Output

Performs the / operation. Read more
source§

impl<'a, T, P> Div for &'a GenericDecimal<T, P>
where T: Clone + GenericInteger + Div, P: Copy + GenericInteger + Into<usize>, &'a T: Div<Output = T>,

§

type Output = GenericDecimal<T, P>

The resulting type after applying the / operator.
source§

fn div(self, other: Self) -> Self::Output

Performs the / operation. Read more
source§

impl<'a, T, P> DivAssign<&'a GenericDecimal<T, P>> for GenericDecimal<T, P>

source§

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

Performs the /= operation. Read more
source§

impl<O, T, P> DivAssign<O> for GenericDecimal<T, P>
where T: Clone + GenericInteger, P: Copy + GenericInteger + Into<usize>, O: Into<Self>,

source§

fn div_assign(&mut self, other: O)

Performs the /= operation. Read more
source§

impl<'a, T, P> From<&'a str> for GenericDecimal<T, P>

source§

fn from(value: &'a str) -> Self

Converts to this type from the input type.
source§

impl<T, P> From<BigInt> for GenericDecimal<T, P>

source§

fn from(value: BigInt) -> Self

Converts to this type from the input type.
source§

impl<T, P> From<BigUint> for GenericDecimal<T, P>

source§

fn from(value: BigUint) -> Self

Converts to this type from the input type.
source§

impl<T, P> From<f32> for GenericDecimal<T, P>

source§

fn from(value: f32) -> Self

Converts to this type from the input type.
source§

impl<T, P> From<f64> for GenericDecimal<T, P>

source§

fn from(value: f64) -> Self

Converts to this type from the input type.
source§

impl<T, P> From<i128> for GenericDecimal<T, P>

source§

fn from(value: i128) -> Self

Converts to this type from the input type.
source§

impl<T, P> From<i16> for GenericDecimal<T, P>

source§

fn from(value: i16) -> Self

Converts to this type from the input type.
source§

impl<T, P> From<i32> for GenericDecimal<T, P>

source§

fn from(value: i32) -> Self

Converts to this type from the input type.
source§

impl<T, P> From<i64> for GenericDecimal<T, P>

source§

fn from(value: i64) -> Self

Converts to this type from the input type.
source§

impl<T, P> From<i8> for GenericDecimal<T, P>

source§

fn from(value: i8) -> Self

Converts to this type from the input type.
source§

impl<T, P> From<isize> for GenericDecimal<T, P>

source§

fn from(value: isize) -> Self

Converts to this type from the input type.
source§

impl<T, P> From<u128> for GenericDecimal<T, P>

source§

fn from(value: u128) -> Self

Converts to this type from the input type.
source§

impl<T, P> From<u16> for GenericDecimal<T, P>

source§

fn from(value: u16) -> Self

Converts to this type from the input type.
source§

impl<T, P> From<u32> for GenericDecimal<T, P>

source§

fn from(value: u32) -> Self

Converts to this type from the input type.
source§

impl<T, P> From<u64> for GenericDecimal<T, P>

source§

fn from(value: u64) -> Self

Converts to this type from the input type.
source§

impl<T, P> From<u8> for GenericDecimal<T, P>

source§

fn from(value: u8) -> Self

Converts to this type from the input type.
source§

impl<T, P> From<usize> for GenericDecimal<T, P>

source§

fn from(value: usize) -> Self

Converts to this type from the input type.
source§

impl<S, T, P> FromInputValue<S> for GenericDecimal<T, P>

source§

fn from_input_value(value: &InputValue<S>) -> Option<Self>

Performs the conversion.
source§

fn from_implicit_null() -> Self

Performs the conversion from an absent value (e.g. to distinguish between implicit and explicit null). The default implementation just uses from_input_value as if an explicit null were provided. This conversion must not fail.
source§

impl<'a, T, P> FromSql<'a> for GenericDecimal<T, P>

source§

fn from_sql(ty: &Type, raw: &[u8]) -> Result<Self, Box<dyn Error + Sync + Send>>

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 + Sync + Send>>

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 + Sync + Send>>

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

impl<T, P> FromStr for GenericDecimal<T, P>

§

type Err = ParseError

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

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

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

impl<S, T, P> GraphQLType<S> for GenericDecimal<T, P>

source§

fn name(_: &Self::TypeInfo) -> Option<&'static str>

Returns name of this GraphQLType to expose. Read more
source§

fn meta<'r>( info: &Self::TypeInfo, registry: &mut Registry<'r, S> ) -> MetaType<'r, S>
where S: 'r,

Returns MetaType representing this GraphQLType.
source§

impl<S, T, P> GraphQLValue<S> for GenericDecimal<T, P>

§

type Context = ()

Context type for this GraphQLValue. Read more
§

type TypeInfo = ()

Type that may carry additional schema information for this GraphQLValue. Read more
source§

fn type_name<'__i>(&self, info: &'__i Self::TypeInfo) -> Option<&'__i str>

Returns name of the GraphQLType exposed by this GraphQLValue. Read more
source§

fn resolve( &self, _info: &(), _selection: Option<&[Selection<'_, S>]>, _executor: &Executor<'_, '_, Self::Context, S> ) -> ExecutionResult<S>

Resolves the provided selection_set against this GraphQLValue. Read more
source§

fn resolve_field( &self, _info: &Self::TypeInfo, _field_name: &str, _arguments: &Arguments<'_, S>, _executor: &Executor<'_, '_, Self::Context, S> ) -> Result<Value<S>, FieldError<S>>

Resolves the value of a single field on this GraphQLValue. Read more
source§

fn resolve_into_type( &self, info: &Self::TypeInfo, type_name: &str, selection_set: Option<&[Selection<'_, S>]>, executor: &Executor<'_, '_, Self::Context, S> ) -> Result<Value<S>, FieldError<S>>

Resolves this GraphQLValue (being an interface or an union) into a concrete downstream object type. Read more
source§

fn concrete_type_name( &self, context: &Self::Context, info: &Self::TypeInfo ) -> String

Returns the concrete GraphQLType name for this GraphQLValue being an interface, an union or an object. Read more
source§

impl<__S, T, P> GraphQLValueAsync<__S> for GenericDecimal<T, P>
where Self: Sync, Self::TypeInfo: Sync, Self::Context: Sync, T: Clone + GenericInteger + From<u8> + Display, P: Copy + GenericInteger + Into<usize> + From<u8>, __S: ScalarValue + Send + Sync,

source§

fn resolve_async<'a>( &'a self, info: &'a Self::TypeInfo, selection_set: Option<&'a [Selection<'_, __S>]>, executor: &'a Executor<'_, '_, Self::Context, __S> ) -> BoxFuture<'a, ExecutionResult<__S>>

Resolves the provided selection_set against this GraphQLValueAsync. Read more
source§

fn resolve_field_async<'a>( &'a self, _info: &'a Self::TypeInfo, _field_name: &'a str, _arguments: &'a Arguments<'_, S>, _executor: &'a Executor<'_, '_, Self::Context, S> ) -> Pin<Box<dyn Future<Output = Result<Value<S>, FieldError<S>>> + Send + 'a>>

Resolves the value of a single field on this GraphQLValueAsync. Read more
source§

fn resolve_into_type_async<'a>( &'a self, info: &'a Self::TypeInfo, type_name: &str, selection_set: Option<&'a [Selection<'a, S>]>, executor: &'a Executor<'a, 'a, Self::Context, S> ) -> Pin<Box<dyn Future<Output = Result<Value<S>, FieldError<S>>> + Send + 'a>>

Resolves this GraphQLValueAsync (being an interface or an union) into a concrete downstream object type. Read more
source§

impl<T, P> Hash for GenericDecimal<T, P>

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<S, T, P> IsInputType<S> for GenericDecimal<T, P>

source§

fn mark()

An arbitrary function without meaning. Read more
source§

impl<S, T, P> IsOutputType<S> for GenericDecimal<T, P>

source§

fn mark()

An arbitrary function without meaning. Read more
source§

impl<'a, O, T, P> Mul<O> for &'a GenericDecimal<T, P>
where T: Clone + GenericInteger, P: Copy + GenericInteger + Into<usize>, &'a T: Mul<Output = T>, O: Into<GenericDecimal<T, P>>,

§

type Output = GenericDecimal<T, P>

The resulting type after applying the * operator.
source§

fn mul(self, other: O) -> Self::Output

Performs the * operation. Read more
source§

impl<O, T, P> Mul<O> for GenericDecimal<T, P>

§

type Output = GenericDecimal<T, P>

The resulting type after applying the * operator.
source§

fn mul(self, other: O) -> Self::Output

Performs the * operation. Read more
source§

impl<'a, T, P> Mul for &'a GenericDecimal<T, P>
where T: Clone + GenericInteger, P: Copy + GenericInteger + Into<usize>, &'a T: Mul<Output = T>,

§

type Output = GenericDecimal<T, P>

The resulting type after applying the * operator.
source§

fn mul(self, other: Self) -> Self::Output

Performs the * operation. Read more
source§

impl<'a, T, P> MulAssign<&'a GenericDecimal<T, P>> for GenericDecimal<T, P>

source§

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

Performs the *= operation. Read more
source§

impl<O, T, P> MulAssign<O> for GenericDecimal<T, P>
where T: Clone + GenericInteger, P: Copy + GenericInteger + Into<usize>, O: Into<Self>,

source§

fn mul_assign(&mut self, other: O)

Performs the *= operation. Read more
source§

impl<'a, T, P> Neg for &'a GenericDecimal<T, P>
where T: Clone + GenericInteger, P: Copy + Integer + Into<usize>, &'a T: Neg<Output = T>,

§

type Output = GenericDecimal<T, P>

The resulting type after applying the - operator.
source§

fn neg(self) -> Self::Output

Performs the unary - operation. Read more
source§

impl<T, P> Neg for GenericDecimal<T, P>
where T: Clone + GenericInteger, P: Copy + Integer + Into<usize>,

§

type Output = GenericDecimal<T, P>

The resulting type after applying the - operator.
source§

fn neg(self) -> Self::Output

Performs the unary - operation. Read more
source§

impl<T, P> Num for GenericDecimal<T, P>

§

type FromStrRadixErr = ParseError

source§

fn from_str_radix(value: &str, base: u32) -> Result<Self, ParseError>

Convert from a string and radix (typically 2..=36). Read more
source§

impl<T, P> One for GenericDecimal<T, P>

source§

fn one() -> Self

Returns the multiplicative identity element of Self, 1. Read more
source§

fn set_one(&mut self)

Sets self to the multiplicative identity element of Self, 1.
source§

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

Returns true if self is equal to the multiplicative identity. Read more
source§

impl<T, P> Ord for GenericDecimal<T, P>

source§

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

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

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

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

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

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

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

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

impl<S, T, P> ParseScalarValue<S> for GenericDecimal<T, P>

source§

fn from_str(value: ScalarToken<'_>) -> ParseScalarResult<'_, S>

See the trait documentation
source§

impl<T, P> PartialEq for GenericDecimal<T, P>

source§

fn eq(&self, other: &Self) -> 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<T, P> PartialOrd for GenericDecimal<T, P>

source§

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

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · 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<'a, T, P> Product<&'a GenericDecimal<T, P>> for GenericDecimal<T, P>

source§

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

Method which takes an iterator and generates Self from the elements by multiplying the items.
source§

impl<T, P> Product for GenericDecimal<T, P>

source§

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

Method which takes an iterator and generates Self from the elements by multiplying the items.
source§

impl<'a, O, T, P> Rem<O> for &'a GenericDecimal<T, P>
where T: Clone + GenericInteger, P: Copy + GenericInteger + Into<usize>, &'a T: Rem<Output = T>, O: Into<GenericDecimal<T, P>>,

§

type Output = GenericDecimal<T, P>

The resulting type after applying the % operator.
source§

fn rem(self, other: O) -> Self::Output

Performs the % operation. Read more
source§

impl<O, T, P> Rem<O> for GenericDecimal<T, P>

§

type Output = GenericDecimal<T, P>

The resulting type after applying the % operator.
source§

fn rem(self, other: O) -> Self::Output

Performs the % operation. Read more
source§

impl<'a, T, P> Rem for &'a GenericDecimal<T, P>
where T: Clone + GenericInteger, P: Copy + GenericInteger + Into<usize>, &'a T: Rem<Output = T>,

§

type Output = GenericDecimal<T, P>

The resulting type after applying the % operator.
source§

fn rem(self, other: Self) -> Self::Output

Performs the % operation. Read more
source§

impl<'a, T, P> RemAssign<&'a GenericDecimal<T, P>> for GenericDecimal<T, P>

source§

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

Performs the %= operation. Read more
source§

impl<O, T, P> RemAssign<O> for GenericDecimal<T, P>
where T: Clone + GenericInteger, P: Copy + GenericInteger + Into<usize>, O: Into<Self>,

source§

fn rem_assign(&mut self, other: O)

Performs the %= operation. Read more
source§

impl<T, P> Serialize for GenericDecimal<T, P>

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<T, P> Signed for GenericDecimal<T, P>

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, O, T, P> Sub<O> for &'a GenericDecimal<T, P>
where T: Clone + GenericInteger, P: Copy + GenericInteger + Into<usize>, &'a T: Sub<Output = T>, O: Into<GenericDecimal<T, P>>,

§

type Output = GenericDecimal<T, P>

The resulting type after applying the - operator.
source§

fn sub(self, other: O) -> Self::Output

Performs the - operation. Read more
source§

impl<O, T, P> Sub<O> for GenericDecimal<T, P>

§

type Output = GenericDecimal<T, P>

The resulting type after applying the - operator.
source§

fn sub(self, other: O) -> Self::Output

Performs the - operation. Read more
source§

impl<'a, T, P> Sub for &'a GenericDecimal<T, P>
where T: Clone + GenericInteger, P: Copy + GenericInteger + Into<usize>, &'a T: Sub<Output = T>,

§

type Output = GenericDecimal<T, P>

The resulting type after applying the - operator.
source§

fn sub(self, other: Self) -> Self::Output

Performs the - operation. Read more
source§

impl<'a, T, P> SubAssign<&'a GenericDecimal<T, P>> for GenericDecimal<T, P>

source§

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

Performs the -= operation. Read more
source§

impl<O, T, P> SubAssign<O> for GenericDecimal<T, P>
where T: Clone + GenericInteger, P: Copy + GenericInteger + Into<usize>, O: Into<Self>,

source§

fn sub_assign(&mut self, other: O)

Performs the -= operation. Read more
source§

impl<'a, T, P> Sum<&'a GenericDecimal<T, P>> for GenericDecimal<T, P>

source§

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

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

impl<T, P> Sum for GenericDecimal<T, P>

source§

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

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

impl<S, T, P> ToInputValue<S> for GenericDecimal<T, P>

source§

fn to_input_value(&self) -> InputValue<S>

Performs the conversion.
source§

impl<T, P> ToPrimitive for GenericDecimal<T, P>

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_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_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_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_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_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_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<T, P> ToSql for GenericDecimal<T, P>

source§

fn to_sql( &self, ty: &Type, buf: &mut BytesMut ) -> Result<IsNull, Box<dyn Error + Sync + Send>>

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§

fn to_sql_checked( &self, ty: &Type, out: &mut BytesMut ) -> Result<IsNull, Box<dyn Error + Sync + Send>>

An adaptor method used internally by Rust-Postgres. Read more
source§

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

Specify the encode format
source§

impl<T, P> TryFrom<GenericDecimal<T, P>> for BigInt

§

type Error = ()

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

fn try_from(value: GenericDecimal<T, P>) -> Result<Self, Self::Error>

Performs the conversion.
source§

impl<T, P> TryFrom<GenericDecimal<T, P>> for BigUint

§

type Error = ()

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

fn try_from(value: GenericDecimal<T, P>) -> Result<Self, Self::Error>

Performs the conversion.
source§

impl<T, P> TryFrom<GenericDecimal<T, P>> for f32

§

type Error = ()

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

fn try_from(value: GenericDecimal<T, P>) -> Result<Self, Self::Error>

Performs the conversion.
source§

impl<T, P> TryFrom<GenericDecimal<T, P>> for f64

§

type Error = ()

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

fn try_from(value: GenericDecimal<T, P>) -> Result<Self, Self::Error>

Performs the conversion.
source§

impl<T, P> TryFrom<GenericDecimal<T, P>> for i128

§

type Error = ()

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

fn try_from(value: GenericDecimal<T, P>) -> Result<Self, Self::Error>

Performs the conversion.
source§

impl<T, P> TryFrom<GenericDecimal<T, P>> for i16

§

type Error = ()

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

fn try_from(value: GenericDecimal<T, P>) -> Result<Self, Self::Error>

Performs the conversion.
source§

impl<T, P> TryFrom<GenericDecimal<T, P>> for i32

§

type Error = ()

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

fn try_from(value: GenericDecimal<T, P>) -> Result<Self, Self::Error>

Performs the conversion.
source§

impl<T, P> TryFrom<GenericDecimal<T, P>> for i64

§

type Error = ()

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

fn try_from(value: GenericDecimal<T, P>) -> Result<Self, Self::Error>

Performs the conversion.
source§

impl<T, P> TryFrom<GenericDecimal<T, P>> for i8

§

type Error = ()

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

fn try_from(value: GenericDecimal<T, P>) -> Result<Self, Self::Error>

Performs the conversion.
source§

impl<T, P> TryFrom<GenericDecimal<T, P>> for isize

§

type Error = ()

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

fn try_from(value: GenericDecimal<T, P>) -> Result<Self, Self::Error>

Performs the conversion.
source§

impl<T, P> TryFrom<GenericDecimal<T, P>> for u128

§

type Error = ()

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

fn try_from(value: GenericDecimal<T, P>) -> Result<Self, Self::Error>

Performs the conversion.
source§

impl<T, P> TryFrom<GenericDecimal<T, P>> for u16

§

type Error = ()

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

fn try_from(value: GenericDecimal<T, P>) -> Result<Self, Self::Error>

Performs the conversion.
source§

impl<T, P> TryFrom<GenericDecimal<T, P>> for u32

§

type Error = ()

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

fn try_from(value: GenericDecimal<T, P>) -> Result<Self, Self::Error>

Performs the conversion.
source§

impl<T, P> TryFrom<GenericDecimal<T, P>> for u64

§

type Error = ()

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

fn try_from(value: GenericDecimal<T, P>) -> Result<Self, Self::Error>

Performs the conversion.
source§

impl<T, P> TryFrom<GenericDecimal<T, P>> for u8

§

type Error = ()

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

fn try_from(value: GenericDecimal<T, P>) -> Result<Self, Self::Error>

Performs the conversion.
source§

impl<T, P> TryFrom<GenericDecimal<T, P>> for usize

§

type Error = ()

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

fn try_from(value: GenericDecimal<T, P>) -> Result<Self, Self::Error>

Performs the conversion.
source§

impl<T, F, P1, P2> TryToConvertFrom<GenericDecimal<F, P1>> for GenericDecimal<T, P2>

source§

impl<T, P> Zero for GenericDecimal<T, P>

source§

fn zero() -> Self

Returns the additive identity element of Self, 0. Read more
source§

fn is_zero(&self) -> bool

Returns true if self is equal to the additive identity.
source§

fn set_zero(&mut self)

Sets self to the additive identity element of Self, 0.
source§

impl<T, P> Copy for GenericDecimal<T, P>
where T: Copy + Integer, P: Copy + Integer + Into<usize>,

source§

impl<T, P> Eq for GenericDecimal<T, P>

Auto Trait Implementations§

§

impl<T, P> Freeze for GenericDecimal<T, P>
where P: Freeze, T: Freeze,

§

impl<T, P> RefUnwindSafe for GenericDecimal<T, P>

§

impl<T, P> Send for GenericDecimal<T, P>
where P: Send, T: Send,

§

impl<T, P> Sync for GenericDecimal<T, P>
where P: Sync, T: Sync,

§

impl<T, P> Unpin for GenericDecimal<T, P>
where P: Unpin, T: Unpin,

§

impl<T, P> UnwindSafe for GenericDecimal<T, P>
where P: UnwindSafe, T: UnwindSafe,

Blanket Implementations§

source§

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

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

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

source§

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

Mutably borrows from an owned value. Read more
source§

impl<T> BorrowToSql for T
where T: ToSql,

source§

fn borrow_to_sql(&self) -> &dyn ToSql

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

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

source§

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

Compare self to key and return their ordering.
source§

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

source§

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

Compare self to key and return true if they are equal.
source§

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

source§

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

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

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

source§

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

Compare self to key and return true if they are equal.
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

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

source§

fn into(self) -> U

Calls U::from(self).

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

source§

impl<T> IntoEither for T

source§

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

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

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

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

impl<T> LowerBounded for T
where T: Bounded,

source§

fn min_value() -> T

Returns the smallest finite number this type can represent
source§

impl<T> Same for T

§

type Output = T

Should always be Self
source§

impl<T> ToOwned for T
where 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 T
where 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 T
where 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 T
where 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§

impl<T> UpperBounded for T
where T: Bounded,

source§

fn max_value() -> T

Returns the largest finite number this type can represent
source§

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

source§

fn vzip(self) -> V

source§

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

source§

impl<T> FromSqlOwned for T
where T: for<'a> FromSql<'a>,

source§

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

source§

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

source§

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

source§

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