[][src]Enum fraction::GenericFraction

pub enum GenericFraction<T> where
    T: Clone + Integer
{ Rational(SignRatio<T>), Infinity(Sign), NaN, }

Generic implementation of the fraction type

Examples

use fraction::GenericFraction;

type F = GenericFraction<u8>;

let first = F::new (1u8, 2u8);
let second = F::new (2u8, 8u8);

assert_eq! (first + second, F::new (3u8, 4u8));

Since GenericFraction keeps its sign explicitly and independently of the numerics, it is not recommended to use signed types, although it's completely valid with the cost of target type capacity.

use fraction::GenericFraction;

type F = GenericFraction<i8>;

let first = F::new (1, 2);
let second = F::new (2, 8);

assert_eq! (first + second, F::new (3, 4));

Variants

Methods

impl<T> GenericFraction<T> where
    T: Clone + Integer
[src]

Constructs a new fraction with the specified numerator and denominator Handles gracefully signed integers even if the storage type is unsigned and vise versa The arguments can be of any integer types imlementing the necessary traits

Examples

use fraction::{GenericFraction, Sign};
type F = GenericFraction<u16>;

let f12 = F::new_generic(Sign::Plus, 1i8, 2u8).unwrap();
let f34 = F::new_generic(Sign::Plus, 3i16, 4u32).unwrap();
let f56 = F::new_generic(Sign::Plus, 5i64, 6u128).unwrap();
let f78 = F::new_generic(Sign::Plus, 7usize, 8isize).unwrap();

assert_eq! ((*f12.numer().unwrap(), *f12.denom().unwrap()), (1u16, 2u16));
assert_eq! ((*f34.numer().unwrap(), *f34.denom().unwrap()), (3u16, 4u16));
assert_eq! ((*f56.numer().unwrap(), *f56.denom().unwrap()), (5u16, 6u16));
assert_eq! ((*f78.numer().unwrap(), *f78.denom().unwrap()), (7u16, 8u16));

Constructs a new fraction with the specified numerator and denominator

The arguments must me either of T type, or implement Into<T> trait.

Examples

use fraction::GenericFraction;
type F = GenericFraction<u16>;

let _f = F::new(1u8, 2u16);

Constructs a new negative fraction with the specified numerator and denominator

The arguments must be either of T type, or implement Into<T> trait.

Examples

use fraction::GenericFraction;
type F = GenericFraction<u16>;

let _f = F::new_neg (1u8, 2u16);

Constructs a new fraction without types casting, checking for denom == 0 and reducing numbers.

You must be careful with this function because all the other functionality parts rely on the numbers to be reduced. That said, in the normal case 2/4 has to be reduced to 1/2, but it will not happen with new_raw.

Examples

use fraction::GenericFraction;
type F = GenericFraction<u8>;

let _f = F::new_raw (1u8, 2u8);

The same as fn new_raw, but produces negative fractions.

Examples

use fraction::GenericFraction;
type F = GenericFraction<u8>;

let _f = F::new_raw_neg (1u8, 2u8);

Deprecated

: Use ::nan()

Constructs NaN value
DEPRECATED! Use nan

Examples

use fraction::GenericFraction;
type F = GenericFraction<u8>;

let _nan = F::new_nan ();

Deprecated

: Use ::infinity()

Constructs INF value
DEPRECATED! Use infinity

Examples

use fraction::GenericFraction;
type F = GenericFraction<u8>;

let _nan = F::new_inf ();

Deprecated

: Use ::neg_infinity()

Constructs negative INF value DEPRECATED! Use neg_infinity

Examples

use fraction::GenericFraction;
type F = GenericFraction<u8>;

let _nan = F::new_inf_neg ();

Returns a reference to the numerator value

Examples

use fraction::GenericFraction;
type F = GenericFraction<u8>;

let fra = F::new (5u8, 6u8);
assert_eq! (5, *fra.numer ().unwrap ());

Returns a reference to the denominator value

Examples

use fraction::GenericFraction;
type F = GenericFraction<u8>;

let fra = F::new (5u8, 6u8);
assert_eq! (6, *fra.denom ().unwrap ());

Returns a reference to the sign value

Examples

use fraction::{ GenericFraction, Sign };
type F = GenericFraction<u8>;


let fra = F::new (5u8, 6u8);
assert_eq! (Sign::Plus, fra.sign ().unwrap ());

let fra = F::new_neg (5u8, 6u8);
assert_eq! (Sign::Minus, fra.sign ().unwrap ());


let fra = F::new_inf ();
assert_eq! (Sign::Plus, fra.sign ().unwrap ());

let fra = F::new_inf_neg ();
assert_eq! (Sign::Minus, fra.sign ().unwrap ());


let fra = F::new_nan ();
assert_eq! (None, fra.sign ());

Generates a GenericFraction from a GenericFraction simply casting underlying values of F into T.

use fraction::{ Fraction, GenericFraction };
type F8 = GenericFraction<u8>;

let fra8 = F8::new (5u8, 6u8);
assert_eq! (Fraction::new (5u64, 6u64), Fraction::from_fraction(fra8));

Deprecated

: Use BigFraction::from_fraction instead

Generates a new BigFraction from the current one DEPRECATED! Use BigFraction::from_fraction instead

Examples

use fraction::{ BigFraction, GenericFraction };
type F = GenericFraction<u8>;

let fra = F::new (5u8, 6u8);
assert_eq! (BigFraction::new (5u8, 6u8), fra.into_big());

Deprecated

: Use format_as_decimal instead

Returns a float representation of the fraction with precision up to 64 digits

DEPRECATED! Use format_as_decimal

Returns None in case we couldn't write the result into a string, e.g. not enough RAM.

Examples

use fraction::GenericFraction;
type F = GenericFraction<u8>;

assert_eq! ("0.5", &F::new (1u8, 2u8).format_as_float ().unwrap ());
assert_eq! ("0.8", &F::new (8u8, 10u8).format_as_float ().unwrap ());
assert_eq! (&F::new (1u8, 3u8).format_as_float().unwrap(), "0.3333333333333333333333333333333333333333333333333333333333333333");

Returns a decimal representation of the fraction

If you have a fraction "1/2", in decimal it should be "0.5".

Returns None in case we couldn't write the result into a string, e.g. not enough RAM.

Examples

use fraction::GenericFraction;
type F = GenericFraction<u8>;

assert_eq! ("0.5", &F::new (1u8, 2u8).format_as_decimal (1).unwrap ());
assert_eq! ("0.8", &F::new (8u8, 10u8).format_as_decimal (2).unwrap ());
assert_eq! (&F::new (1u8, 3u8).format_as_decimal(32).unwrap(), "0.33333333333333333333333333333333");

Parse a decimal string into a fraction and return the result. Returns ParseError::OverflowError if there's not enough space in T to represent the decimal (use BigFraction in such a case) Returns ParseError::ParseIntError if the string contains incorrect junk data (e.g. non-numeric characters). May return ParseIntError if there is not enough volume in T to read whole part of the number into it.

Examples

use fraction::Fraction;

let f = Fraction::from_decimal_str ("1.5");
assert_eq! (f, Ok (Fraction::new(3u8, 2u8)));

impl<T: Clone + Integer> GenericFraction<T>
[src]

Returns NaN value

Examples

use fraction::GenericFraction;
type F = GenericFraction<u8>;

assert_eq! (F::nan (), F::new (0, 0));

Returns positive Infinity value

Examples

use fraction::GenericFraction;
type F = GenericFraction<u8>;

assert_eq! (F::infinity (), F::new (1, 0));

Returns negative Infinity value

Examples

use fraction::GenericFraction;
type F = GenericFraction<u8>;

assert_eq! (F::neg_infinity (), F::new_neg (1, 0));

Returns zero with negative sign

Examples

use fraction::GenericFraction;
type F = GenericFraction<u8>;

assert_eq! (F::neg_zero (), F::new_neg (0, 1));

Returns minimal value greater than zero

Examples

use fraction::GenericFraction;
type F8 = GenericFraction<u8>;
type F16 = GenericFraction<u16>;

assert_eq! (F8::min_positive_value (), F8::new (1u8, 255u8));
assert_eq! (F16::min_positive_value (), F16::new (1u16, 65535u16));

Returns true if the value is NaN

Examples

use fraction::GenericFraction;
type F = GenericFraction<u8>;

assert! (F::nan ().is_nan ());
assert! (F::new (0, 0).is_nan ());

Returns true if the value is Infinity (does not matter positive or negative)

Examples

use fraction::GenericFraction;
type F = GenericFraction<u8>;

assert! (F::infinity ().is_infinite ());
assert! (F::new (1u8, 0).is_infinite ());
assert! (F::new_neg (1u8, 0).is_infinite ());

Returns true if the value is not Infinity (does not matter positive or negative)

Examples

use fraction::GenericFraction;
type F = GenericFraction<u8>;

assert! (! F::infinity ().is_finite ());
assert! (! F::new (1u8, 0).is_finite ());
assert! (! F::new_neg (1u8, 0).is_finite ());

Returns true if the number is neither zero, Infinity or NaN

Examples

use fraction::GenericFraction;
type F = GenericFraction<u8>;

assert! (! F::nan ().is_normal ());
assert! (! F::infinity ().is_normal ());
assert! (! F::neg_infinity ().is_normal ());
assert! (! F::new (0, 1u8).is_normal ());
assert! (! F::neg_zero ().is_normal ());

Returns the floating point category of the number

Examples

use std::num::FpCategory;
use fraction::GenericFraction;
type F = GenericFraction<u8>;

assert_eq! (F::nan ().classify (), FpCategory::Nan);
assert_eq! (F::infinity ().classify (), FpCategory::Infinite);
assert_eq! (F::new (0, 1u8).classify (), FpCategory::Zero);
assert_eq! (F::new (1u8, 1u8).classify (), FpCategory::Normal);

Returns the largest integer less than or equal to the value

Examples

use fraction::GenericFraction;
type F = GenericFraction<u8>;

assert_eq! (F::new (7u8, 5u8).floor (), F::new (5u8, 5u8));

Returns the smallest integer greater than or equal to the value

Examples

use fraction::GenericFraction;
type F = GenericFraction<u8>;

assert_eq! (F::new (7u8, 5u8).ceil (), F::new (10u8, 5u8));

Returns the nearest integer to the value (.5 goes up)

Examples

use fraction::GenericFraction;
type F = GenericFraction<u8>;

assert_eq! (F::new (7u8, 5u8).round (), F::new (5u8, 5u8));
assert_eq! (F::new (8u8, 5u8).round (), F::new (10u8, 5u8));
assert_eq! (F::new (3u8, 2u8).round (), F::new (4u8, 2u8));
assert_eq! (F::new (1u8, 2u8).round (), F::new (2u8, 2u8));

Returns the integer part of the value

Examples

use fraction::GenericFraction;
type F = GenericFraction<u8>;

assert_eq! (F::new (7u8, 5u8).trunc (), F::new (5u8, 5u8));
assert_eq! (F::new (8u8, 5u8).trunc (), F::new (5u8, 5u8));

Returns the fractional part of a number

Examples

use fraction::GenericFraction;
type F = GenericFraction<u8>;

assert_eq! (F::new (7u8, 5u8).fract (), F::new (2u8, 5u8));
assert_eq! (F::new (8u8, 5u8).fract (), F::new (3u8, 5u8));

Returns the absolute value of self

Examples

use fraction::GenericFraction;
type F = GenericFraction<u8>;

assert_eq! (F::nan ().abs (), F::nan ());
assert_eq! (F::infinity ().abs (), F::infinity ());
assert_eq! (F::neg_infinity ().abs (), F::infinity ());
assert_eq! (F::new (1u8, 2u8).abs (), F::new (1u8, 2u8));
assert_eq! (F::new_neg (1u8, 2u8).abs (), F::new (1u8, 2u8));

Returns a number that represents the sign of self

  • 1.0 if the number is positive, +0.0 or INFINITY
  • -1.0 if the number is negative, -0.0 or NEG_INFINITY
  • NAN if the number is NAN

Examples

use fraction::GenericFraction;
type F = GenericFraction<u8>;

assert_eq! (F::new (1u8, 2u8).signum (), F::new (1u8, 1u8));
assert_eq! (F::new (0u8, 1u8).signum (), F::new (1u8, 1u8));
assert_eq! (F::infinity ().signum (), F::new (1u8, 1u8));
assert_eq! (F::new_neg (1u8, 2u8).signum (), F::new_neg (1u8, 1u8));
assert_eq! (F::neg_zero ().signum (), F::new_neg (1u8, 1u8));
assert_eq! (F::neg_infinity ().signum (), F::new_neg (1u8, 1u8));
assert_eq! (F::nan ().signum (), F::nan ());

Returns true if the sign is positive

Examples

use fraction::GenericFraction;
type F = GenericFraction<u8>;

assert! (F::new (1u8, 2u8).is_sign_positive ());
assert! (F::infinity ().is_sign_positive ());
assert! (! F::nan ().is_sign_positive ());

Returns true if the sign is negative

Examples

use fraction::GenericFraction;
type F = GenericFraction<u8>;

assert! (F::new_neg (1u8, 2u8).is_sign_negative ());
assert! (F::neg_zero ().is_sign_negative ());
assert! (F::neg_infinity ().is_sign_negative ());
assert! (! F::nan ().is_sign_negative ());

self.clone () * a + b

Added for interface compatibility with float types

Takes the reciprocal (inverse) of the value (1/x)

Examples

use fraction::GenericFraction;
type F = GenericFraction<u8>;

assert_eq! (F::new (1u8, 2u8).recip (), F::new (2u8, 1u8));
assert_eq! (F::new (0u8, 1u8).recip (), F::infinity ());
assert_eq! (F::infinity ().recip (), F::new (0u8, 1u8));
assert_eq! (F::nan ().recip (), F::nan ());

Trait Implementations

impl<T, F> TryToConvertFrom<GenericFraction<F>> for GenericFraction<T> where
    T: TryToConvertFrom<F> + Clone + Integer,
    F: Clone + Integer
[src]

impl<T: Clone + Integer> PartialOrd<GenericFraction<T>> for GenericFraction<T>
[src]

This method returns an ordering between self and other values if one exists. Read more

This method tests less than (for self and other) and is used by the < operator. Read more

This method tests less than or equal to (for self and other) and is used by the <= operator. Read more

This method tests greater than (for self and other) and is used by the > operator. Read more

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

impl<T: Clone + Integer> PartialEq<GenericFraction<T>> for GenericFraction<T>
[src]

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.

impl<T> From<BigUint> for GenericFraction<T> where
    T: Clone + Integer + GenericInteger + CheckedAdd + CheckedMul + CheckedSub,
    BigUint: GenericInteger + CheckedAdd + CheckedDiv + CheckedMul + CheckedSub + PartialOrd
[src]

Performs the conversion.

impl<T> From<BigInt> for GenericFraction<T> where
    T: Clone + Integer + GenericInteger + CheckedAdd + CheckedMul + CheckedSub,
    BigInt: GenericInteger + CheckedAdd + CheckedDiv + CheckedMul + CheckedSub + PartialOrd
[src]

Performs the conversion.

impl<T> From<u8> for GenericFraction<T> where
    T: Clone + Integer + GenericInteger + CheckedAdd + CheckedMul + CheckedSub,
    u8: GenericInteger + CheckedAdd + CheckedDiv + CheckedMul + CheckedSub + PartialOrd
[src]

Performs the conversion.

impl<T> From<i8> for GenericFraction<T> where
    T: Clone + Integer + GenericInteger + CheckedAdd + CheckedMul + CheckedSub,
    i8: GenericInteger + CheckedAdd + CheckedDiv + CheckedMul + CheckedSub + PartialOrd
[src]

Performs the conversion.

impl<T> From<u16> for GenericFraction<T> where
    T: Clone + Integer + GenericInteger + CheckedAdd + CheckedMul + CheckedSub,
    u16: GenericInteger + CheckedAdd + CheckedDiv + CheckedMul + CheckedSub + PartialOrd
[src]

Performs the conversion.

impl<T> From<i16> for GenericFraction<T> where
    T: Clone + Integer + GenericInteger + CheckedAdd + CheckedMul + CheckedSub,
    i16: GenericInteger + CheckedAdd + CheckedDiv + CheckedMul + CheckedSub + PartialOrd
[src]

Performs the conversion.

impl<T> From<u32> for GenericFraction<T> where
    T: Clone + Integer + GenericInteger + CheckedAdd + CheckedMul + CheckedSub,
    u32: GenericInteger + CheckedAdd + CheckedDiv + CheckedMul + CheckedSub + PartialOrd
[src]

Performs the conversion.

impl<T> From<i32> for GenericFraction<T> where
    T: Clone + Integer + GenericInteger + CheckedAdd + CheckedMul + CheckedSub,
    i32: GenericInteger + CheckedAdd + CheckedDiv + CheckedMul + CheckedSub + PartialOrd
[src]

Performs the conversion.

impl<T> From<u64> for GenericFraction<T> where
    T: Clone + Integer + GenericInteger + CheckedAdd + CheckedMul + CheckedSub,
    u64: GenericInteger + CheckedAdd + CheckedDiv + CheckedMul + CheckedSub + PartialOrd
[src]

Performs the conversion.

impl<T> From<i64> for GenericFraction<T> where
    T: Clone + Integer + GenericInteger + CheckedAdd + CheckedMul + CheckedSub,
    i64: GenericInteger + CheckedAdd + CheckedDiv + CheckedMul + CheckedSub + PartialOrd
[src]

Performs the conversion.

impl<T> From<u128> for GenericFraction<T> where
    T: Clone + Integer + GenericInteger + CheckedAdd + CheckedMul + CheckedSub,
    u128: GenericInteger + CheckedAdd + CheckedDiv + CheckedMul + CheckedSub + PartialOrd
[src]

Performs the conversion.

impl<T> From<i128> for GenericFraction<T> where
    T: Clone + Integer + GenericInteger + CheckedAdd + CheckedMul + CheckedSub,
    i128: GenericInteger + CheckedAdd + CheckedDiv + CheckedMul + CheckedSub + PartialOrd
[src]

Performs the conversion.

impl<T> From<usize> for GenericFraction<T> where
    T: Clone + Integer + GenericInteger + CheckedAdd + CheckedMul + CheckedSub,
    usize: GenericInteger + CheckedAdd + CheckedDiv + CheckedMul + CheckedSub + PartialOrd
[src]

Performs the conversion.

impl<T> From<isize> for GenericFraction<T> where
    T: Clone + Integer + GenericInteger + CheckedAdd + CheckedMul + CheckedSub,
    isize: GenericInteger + CheckedAdd + CheckedDiv + CheckedMul + CheckedSub + PartialOrd
[src]

Performs the conversion.

impl<T: Clone + Integer + CheckedAdd + CheckedMul + CheckedSub> From<f32> for GenericFraction<T>
[src]

Performs the conversion.

impl<T: Clone + Integer + CheckedAdd + CheckedMul + CheckedSub> From<f64> for GenericFraction<T>
[src]

Performs the conversion.

impl<T, N, D> From<(N, D)> for GenericFraction<T> where
    T: Clone + Integer,
    N: Display,
    D: Display
[src]

Performs the conversion.

impl<T: Clone> Clone for GenericFraction<T> where
    T: Clone + Integer
[src]

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

impl<T> Copy for GenericFraction<T> where
    T: Copy + Integer
[src]

Copy semantics to be applied for the target type, but only if T also has it.

impl<T: Clone + Integer> Eq for GenericFraction<T>
[src]

impl<T: Debug> Debug for GenericFraction<T> where
    T: Clone + Integer
[src]

Formats the value using the given formatter. Read more

impl<T: Display + Eq + One + Clone + Integer> Display for GenericFraction<T>
[src]

Formats the value using the given formatter. Read more

impl<T: Clone + Integer> Sub<GenericFraction<T>> for GenericFraction<T>
[src]

The resulting type after applying the - operator.

Performs the - operation.

impl<'a, T> Sub<&'a GenericFraction<T>> for &'a GenericFraction<T> where
    T: Clone + Integer
[src]

The resulting type after applying the - operator.

Performs the - operation.

impl<T: Clone + Integer> Add<GenericFraction<T>> for GenericFraction<T>
[src]

The resulting type after applying the + operator.

Performs the + operation.

impl<'a, T> Add<&'a GenericFraction<T>> for &'a GenericFraction<T> where
    T: Clone + Integer
[src]

The resulting type after applying the + operator.

Performs the + operation.

impl<T: Clone + Integer> Mul<GenericFraction<T>> for GenericFraction<T>
[src]

The resulting type after applying the * operator.

Performs the * operation.

impl<'a, T> Mul<&'a GenericFraction<T>> for &'a GenericFraction<T> where
    T: Clone + Integer
[src]

The resulting type after applying the * operator.

Performs the * operation.

impl<T: Clone + Integer> Div<GenericFraction<T>> for GenericFraction<T>
[src]

The resulting type after applying the / operator.

Performs the / operation.

impl<'a, T> Div<&'a GenericFraction<T>> for &'a GenericFraction<T> where
    T: Clone + Integer
[src]

The resulting type after applying the / operator.

Performs the / operation.

impl<T: Clone + Integer> Rem<GenericFraction<T>> for GenericFraction<T>
[src]

The resulting type after applying the % operator.

Performs the % operation.

impl<'a, T> Rem<&'a GenericFraction<T>> for &'a GenericFraction<T> where
    T: Clone + Integer
[src]

The resulting type after applying the % operator.

Performs the % operation.

impl<T: Clone + Integer> Neg for GenericFraction<T>
[src]

The resulting type after applying the - operator.

Performs the unary - operation.

impl<'a, T: Clone + Integer> Neg for &'a GenericFraction<T>
[src]

The resulting type after applying the - operator.

Performs the unary - operation.

impl<T: Clone + Integer> AddAssign<GenericFraction<T>> for GenericFraction<T>
[src]

Performs the += operation.

impl<'a, T> AddAssign<&'a GenericFraction<T>> for GenericFraction<T> where
    T: Clone + Integer
[src]

Performs the += operation.

impl<T: Clone + Integer> SubAssign<GenericFraction<T>> for GenericFraction<T>
[src]

Performs the -= operation.

impl<'a, T> SubAssign<&'a GenericFraction<T>> for GenericFraction<T> where
    T: Clone + Integer
[src]

Performs the -= operation.

impl<T: Clone + Integer> MulAssign<GenericFraction<T>> for GenericFraction<T>
[src]

Performs the *= operation.

impl<'a, T> MulAssign<&'a GenericFraction<T>> for GenericFraction<T> where
    T: Clone + Integer
[src]

Performs the *= operation.

impl<T: Clone + Integer> DivAssign<GenericFraction<T>> for GenericFraction<T>
[src]

Performs the /= operation.

impl<'a, T> DivAssign<&'a GenericFraction<T>> for GenericFraction<T> where
    T: Clone + Integer
[src]

Performs the /= operation.

impl<T: Clone + Integer> RemAssign<GenericFraction<T>> for GenericFraction<T>
[src]

Performs the %= operation.

impl<'a, T> RemAssign<&'a GenericFraction<T>> for GenericFraction<T> where
    T: Clone + Integer
[src]

Performs the %= operation.

impl<T: Clone + Integer + Hash> Hash for GenericFraction<T>
[src]

Feeds this value into the given [Hasher]. Read more

Feeds a slice of this type into the given [Hasher]. Read more

impl<T: Clone + Integer + PartialEq + ToPrimitive> ToPrimitive for GenericFraction<T>
[src]

Converts the value of self to an i64.

Converts the value of self to an u64.

Converts the value of self to an f64.

Converts the value of self to an isize.

Converts the value of self to an i8.

Converts the value of self to an i16.

Converts the value of self to an i32.

Converts the value of self to an i128. Read more

Converts the value of self to a usize.

Converts the value of self to an u8.

Converts the value of self to an u16.

Converts the value of self to an u32.

Converts the value of self to an u128. Read more

Converts the value of self to an f32.

impl<T: Clone + Integer> Num for GenericFraction<T>
[src]

Convert from a string and radix <= 36. Read more

impl<T: Bounded + Clone + Integer> Bounded for GenericFraction<T>
[src]

returns the smallest finite number this type can represent

returns the largest finite number this type can represent

impl<T: Clone + Integer> Zero for GenericFraction<T>
[src]

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

Returns true if self is equal to the additive identity.

impl<T: Clone + Integer> One for GenericFraction<T>
[src]

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

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

impl<T> CheckedSub for GenericFraction<T> where
    T: Clone + Integer + CheckedAdd + CheckedSub + CheckedMul
[src]

Subtracts two numbers, checking for underflow. If underflow happens, None is returned. Read more

impl<T> CheckedAdd for GenericFraction<T> where
    T: Clone + Integer + CheckedAdd + CheckedSub + CheckedMul
[src]

Adds two numbers, checking for overflow. If overflow happens, None is returned. Read more

impl<T> CheckedMul for GenericFraction<T> where
    T: Clone + Integer + CheckedMul
[src]

Multiplies two numbers, checking for underflow or overflow. If underflow or overflow happens, None is returned. Read more

impl<T> CheckedDiv for GenericFraction<T> where
    T: Clone + Integer + CheckedDiv + CheckedMul
[src]

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

impl<T: Clone + Integer> Signed for GenericFraction<T>
[src]

Computes the absolute value. Read more

The positive difference of two numbers. Read more

Returns the sign of the number. Read more

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

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

impl<T> Serialize for GenericFraction<T> where
    T: Clone + Integer,
    T: Serialize
[src]

Serialize this value into the given Serde serializer. Read more

impl<'de, T> Deserialize<'de> for GenericFraction<T> where
    T: Clone + Integer,
    T: Deserialize<'de>, 
[src]

Deserialize this value from the given Serde deserializer. Read more

impl<T> ToInputValue for GenericFraction<T> where
    T: Clone + Integer + Display
[src]

Performs the conversion.

impl<T> FromInputValue for GenericFraction<T> where
    T: Clone + Integer + CheckedAdd + CheckedMul + CheckedSub + Num + One
[src]

Performs the conversion.

impl<T> GraphQLType for GenericFraction<T> where
    T: Clone + Integer + CheckedAdd + CheckedMul + CheckedSub + Display
[src]

The expected context type for this GraphQL type Read more

Type that may carry additional schema information Read more

The name of the GraphQL type to expose. Read more

The meta type representing this GraphQL type.

Resolve the provided selection set against the current object. Read more

Resolve the value of a single field on this type. Read more

Resolve this interface or union into a concrete type Read more

Return the concrete type name for this instance/union. Read more

impl<T> ToSql for GenericFraction<T> where
    T: Clone + GenericInteger + From<u8> + Debug
[src]

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

Determines if a value of this type can be converted to the specified Postgres Type. Read more

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

impl<T> FromSql for GenericFraction<T> where
    T: Clone + GenericInteger + From<u16>, 
[src]

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

Determines if a value of this type can be created from the specified Postgres Type. Read more

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

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

Auto Trait Implementations

impl<T> Send for GenericFraction<T> where
    T: Send

impl<T> Sync for GenericFraction<T> where
    T: Sync

Blanket Implementations

impl<T, U> Into for T where
    U: From<T>, 
[src]

Performs the conversion.

impl<T> ToString for T where
    T: Display + ?Sized
[src]

Converts the given value to a String. Read more

impl<T> ToOwned for T where
    T: Clone
[src]

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

🔬 This is a nightly-only experimental API. (toowned_clone_into)

recently added

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

impl<T> From for T
[src]

Performs the conversion.

impl<T, U> TryFrom for T where
    T: From<U>, 
[src]

🔬 This is a nightly-only experimental API. (try_from)

The type returned in the event of a conversion error.

🔬 This is a nightly-only experimental API. (try_from)

Performs the conversion.

impl<T> Borrow for T where
    T: ?Sized
[src]

Immutably borrows from an owned value. Read more

impl<T> BorrowMut for T where
    T: ?Sized
[src]

Mutably borrows from an owned value. Read more

impl<T, U> TryInto for T where
    U: TryFrom<T>, 
[src]

🔬 This is a nightly-only experimental API. (try_from)

The type returned in the event of a conversion error.

🔬 This is a nightly-only experimental API. (try_from)

Performs the conversion.

impl<T> Any for T where
    T: 'static + ?Sized
[src]

🔬 This is a nightly-only experimental API. (get_type_id)

this method will likely be replaced by an associated static

Gets the TypeId of self. Read more

impl<T, Rhs, Output> NumOps 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]

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

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

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

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

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

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

impl<T> Same for T

Should always be Self