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

source§

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>

source§

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

source§

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

source§

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

source§

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

source§

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

source§

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<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<'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>>,

source§

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>

source§

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

source§

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

source§

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

source§

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>

source§

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

source§

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

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

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

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

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

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

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

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · source§

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

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

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

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

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

source§

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

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

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

source§

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>

source§

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

source§

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

source§

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>

source§

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

source§

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

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

Takes an iterator and generates Self from the elements by “summing up” the items.
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> TryFrom<GenericDecimal<T, P>> for BigInt

source§

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

source§

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

source§

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

source§

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

source§

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

source§

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

source§

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

source§

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

source§

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

source§

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

source§

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

source§

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

source§

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

source§

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

source§

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

source§

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> CloneToUninit for T
where T: Clone,

source§

unsafe fn clone_to_uninit(&self, dst: *mut T)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. Read more
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> LowerBounded for T
where T: Bounded,

source§

fn min_value() -> T

Returns the smallest finite number this type can represent
source§

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

source§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

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

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

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

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

source§

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

source§

type Error = Infallible

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

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

Performs the conversion.
source§

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

source§

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

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

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

Performs the conversion.
source§

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

source§

fn max_value() -> T

Returns the largest finite number this type can represent
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>,