Enum fraction::GenericFraction
source · pub enum GenericFraction<T>{
Rational(Sign, Ratio<T>),
Infinity(Sign),
NaN,
}
Expand description
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§
Implementations§
source§impl<T> GenericFraction<T>
impl<T> GenericFraction<T>
sourcepub fn new_generic<N, D>(
sign: Sign,
num: N,
den: D,
) -> Option<GenericFraction<T>>
pub fn new_generic<N, D>( sign: Sign, num: N, den: D, ) -> Option<GenericFraction<T>>
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));
sourcepub fn new<N, D>(num: N, den: D) -> GenericFraction<T>
pub fn new<N, D>(num: N, den: D) -> GenericFraction<T>
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);
sourcepub fn new_neg<N, D>(num: N, den: D) -> GenericFraction<T>
pub fn new_neg<N, D>(num: N, den: D) -> GenericFraction<T>
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);
sourcepub const fn new_raw(num: T, den: T) -> GenericFraction<T>
pub const fn new_raw(num: T, den: T) -> GenericFraction<T>
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);
sourcepub const fn new_raw_signed(sign: Sign, num: T, den: T) -> GenericFraction<T>
pub const fn new_raw_signed(sign: Sign, num: T, den: T) -> GenericFraction<T>
The same as fn new_raw, but allows explicitly set sign.
§Examples
use fraction::{GenericFraction, Sign};
type F = GenericFraction<u8>;
let _f = F::new_raw_signed(Sign::Minus, 1u8, 2u8);
sourcepub const fn numer(&self) -> Option<&T>
pub const fn numer(&self) -> Option<&T>
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 ());
sourcepub const fn denom(&self) -> Option<&T>
pub const fn denom(&self) -> Option<&T>
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 ());
sourcepub const fn sign(&self) -> Option<Sign>
pub const fn sign(&self) -> Option<Sign>
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::infinity ();
assert_eq! (Sign::Plus, fra.sign ().unwrap ());
let fra = F::neg_infinity ();
assert_eq! (Sign::Minus, fra.sign ().unwrap ());
let fra = F::nan ();
assert_eq! (None, fra.sign ());
sourcepub fn from_fraction<F>(from: GenericFraction<F>) -> GenericFraction<T>
pub fn from_fraction<F>(from: GenericFraction<F>) -> GenericFraction<T>
Generates a GenericFraction
use fraction::{ Fraction, GenericFraction };
type F8 = GenericFraction<u8>;
let fra8 = F8::new (5u8, 6u8);
assert_eq! (Fraction::new (5u64, 6u64), Fraction::from_fraction(fra8));
sourcepub fn into_fraction<I>(self) -> GenericFraction<I>
pub fn into_fraction<I>(self) -> GenericFraction<I>
Generates a GenericFraction from GenericFraction
use fraction::{ Fraction, GenericFraction };
type F8 = GenericFraction<u8>;
let fra8 = F8::new (5u8, 6u8);
assert_eq! (Fraction::new (5u64, 6u64), fra8.into_fraction());
source§impl<T: Clone + Integer> GenericFraction<T>
impl<T: Clone + Integer> GenericFraction<T>
sourcepub const fn nan() -> Self
pub const fn nan() -> Self
Returns NaN value
§Examples
use fraction::GenericFraction;
type F = GenericFraction<u8>;
assert_eq! (F::nan (), F::new (0, 0));
sourcepub const fn infinity() -> Self
pub const fn infinity() -> Self
Returns positive Infinity value
§Examples
use fraction::GenericFraction;
type F = GenericFraction<u8>;
assert_eq! (F::infinity (), F::new (1, 0));
sourcepub const fn neg_infinity() -> Self
pub const fn neg_infinity() -> Self
Returns negative Infinity value
§Examples
use fraction::GenericFraction;
type F = GenericFraction<u8>;
assert_eq! (F::neg_infinity (), F::new_neg (1, 0));
sourcepub fn neg_zero() -> Self
pub fn neg_zero() -> Self
Returns zero with negative sign
§Examples
use fraction::GenericFraction;
type F = GenericFraction<u8>;
assert_eq! (F::neg_zero (), F::new_neg (0, 1));
sourcepub fn min_positive_value() -> Selfwhere
T: Bounded,
pub fn min_positive_value() -> Selfwhere
T: Bounded,
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));
sourcepub const fn is_nan(&self) -> bool
pub const fn is_nan(&self) -> bool
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 ());
sourcepub const fn is_infinite(&self) -> bool
pub const fn is_infinite(&self) -> bool
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 ());
sourcepub const fn is_finite(&self) -> bool
pub const fn is_finite(&self) -> bool
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 ());
sourcepub fn is_normal(&self) -> bool
pub fn is_normal(&self) -> bool
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 ());
sourcepub fn classify(&self) -> FpCategory
pub fn classify(&self) -> FpCategory
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);
sourcepub fn floor(&self) -> Self
pub fn floor(&self) -> Self
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));
assert_eq! (F::new_neg (4u8, 3u8).floor (), F::new_neg (2u8, 1u8));
sourcepub fn ceil(&self) -> Self
pub fn ceil(&self) -> Self
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));
assert_eq! (F::new_neg (4u8, 3u8).ceil (), F::new_neg (1u8, 1u8));
sourcepub fn round(&self) -> Self
pub fn round(&self) -> Self
Returns the nearest integer to the value (.5 goes away from zero)
§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));
assert_eq! (F::new_neg (3u8, 2u8).round (), F::new_neg (2u8, 1u8));
sourcepub fn trunc(&self) -> Self
pub fn trunc(&self) -> Self
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));
sourcepub fn fract(&self) -> Self
pub fn fract(&self) -> Self
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));
sourcepub fn abs(&self) -> Self
pub fn abs(&self) -> Self
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));
sourcepub fn signum(&self) -> Self
pub fn signum(&self) -> Self
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 ());
sourcepub const fn is_sign_positive(&self) -> bool
pub const fn is_sign_positive(&self) -> bool
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 ());
sourcepub const fn is_sign_negative(&self) -> bool
pub const fn is_sign_negative(&self) -> bool
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 ());
sourcepub fn mul_add(&self, a: Self, b: Self) -> Self
pub fn mul_add(&self, a: Self, b: Self) -> Self
self.clone () * a + b
Added for interface compatibility with float types
sourcepub fn recip(&self) -> Self
pub fn recip(&self) -> Self
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§
source§impl<'a, T, O> Add<O> for &'a GenericFraction<T>
impl<'a, T, O> Add<O> for &'a GenericFraction<T>
source§type Output = GenericFraction<T>
type Output = GenericFraction<T>
+
operator.source§fn add(self, other: O) -> GenericFraction<T>
fn add(self, other: O) -> GenericFraction<T>
+
operation. Read moresource§impl<T, O> Add<O> for GenericFraction<T>
impl<T, O> Add<O> for GenericFraction<T>
source§impl<'a, T> Add for &'a GenericFraction<T>
impl<'a, T> Add for &'a GenericFraction<T>
source§type Output = GenericFraction<T>
type Output = GenericFraction<T>
+
operator.source§fn add(self, other: Self) -> GenericFraction<T>
fn add(self, other: Self) -> GenericFraction<T>
+
operation. Read moresource§impl<'a, T> AddAssign<&'a GenericFraction<T>> for GenericFraction<T>
impl<'a, T> AddAssign<&'a GenericFraction<T>> for GenericFraction<T>
source§fn add_assign(&mut self, other: &'a Self)
fn add_assign(&mut self, other: &'a Self)
+=
operation. Read moresource§impl<T, O> AddAssign<O> for GenericFraction<T>
impl<T, O> AddAssign<O> for GenericFraction<T>
source§fn add_assign(&mut self, other: O)
fn add_assign(&mut self, other: O)
+=
operation. Read moresource§impl<T> CheckedAdd for GenericFraction<T>
impl<T> CheckedAdd for GenericFraction<T>
source§fn checked_add(&self, other: &Self) -> Option<GenericFraction<T>>
fn checked_add(&self, other: &Self) -> Option<GenericFraction<T>>
None
is
returned.source§impl<T> CheckedDiv for GenericFraction<T>
impl<T> CheckedDiv for GenericFraction<T>
source§fn checked_div(&self, other: &Self) -> Option<GenericFraction<T>>
fn checked_div(&self, other: &Self) -> Option<GenericFraction<T>>
None
is returned.source§impl<T> CheckedMul for GenericFraction<T>
impl<T> CheckedMul for GenericFraction<T>
source§fn checked_mul(&self, other: &Self) -> Option<GenericFraction<T>>
fn checked_mul(&self, other: &Self) -> Option<GenericFraction<T>>
None
is returned.source§impl<T> CheckedSub for GenericFraction<T>
impl<T> CheckedSub for GenericFraction<T>
source§fn checked_sub(&self, other: &Self) -> Option<GenericFraction<T>>
fn checked_sub(&self, other: &Self) -> Option<GenericFraction<T>>
None
is returned.source§impl<T> Clone for GenericFraction<T>
impl<T> Clone for GenericFraction<T>
source§fn clone(&self) -> GenericFraction<T>
fn clone(&self) -> GenericFraction<T>
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moresource§impl<T: ConstOne + Integer + Clone> ConstOne for GenericFraction<T>
impl<T: ConstOne + Integer + Clone> ConstOne for GenericFraction<T>
source§const ONE: GenericFraction<T> = _
const ONE: GenericFraction<T> = _
Self
, 1
.source§impl<T: ConstOne + ConstZero + Integer + Clone> ConstZero for GenericFraction<T>
impl<T: ConstOne + ConstZero + Integer + Clone> ConstZero for GenericFraction<T>
source§const ZERO: GenericFraction<T> = _
const ZERO: GenericFraction<T> = _
Self
, 0
.source§impl<T> Debug for GenericFraction<T>
impl<T> Debug for GenericFraction<T>
source§impl<T> Default for GenericFraction<T>
impl<T> Default for GenericFraction<T>
source§impl<T: Clone + GenericInteger> Display for GenericFraction<T>
impl<T: Clone + GenericInteger> Display for GenericFraction<T>
source§impl<'a, T, O> Div<O> for &'a GenericFraction<T>
impl<'a, T, O> Div<O> for &'a GenericFraction<T>
source§type Output = GenericFraction<T>
type Output = GenericFraction<T>
/
operator.source§fn div(self, other: O) -> GenericFraction<T>
fn div(self, other: O) -> GenericFraction<T>
/
operation. Read moresource§impl<T, O> Div<O> for GenericFraction<T>
impl<T, O> Div<O> for GenericFraction<T>
source§impl<'a, T> Div for &'a GenericFraction<T>
impl<'a, T> Div for &'a GenericFraction<T>
source§type Output = GenericFraction<T>
type Output = GenericFraction<T>
/
operator.source§fn div(self, other: Self) -> GenericFraction<T>
fn div(self, other: Self) -> GenericFraction<T>
/
operation. Read moresource§impl<'a, T> DivAssign<&'a GenericFraction<T>> for GenericFraction<T>
impl<'a, T> DivAssign<&'a GenericFraction<T>> for GenericFraction<T>
source§fn div_assign(&mut self, other: &'a Self)
fn div_assign(&mut self, other: &'a Self)
/=
operation. Read moresource§impl<T, O> DivAssign<O> for GenericFraction<T>
impl<T, O> DivAssign<O> for GenericFraction<T>
source§fn div_assign(&mut self, other: O)
fn div_assign(&mut self, other: O)
/=
operation. Read moresource§impl<T, N, D> From<(N, D)> for GenericFraction<T>
impl<T, N, D> From<(N, D)> for GenericFraction<T>
source§fn from(pair: (N, D)) -> GenericFraction<T>
fn from(pair: (N, D)) -> GenericFraction<T>
source§impl<T> From<BigInt> for GenericFraction<T>where
T: Clone + Integer + GenericInteger + CheckedAdd + CheckedMul + CheckedSub,
BigInt: GenericInteger + CheckedAdd + CheckedDiv + CheckedMul + CheckedSub + PartialOrd,
impl<T> From<BigInt> for GenericFraction<T>where
T: Clone + Integer + GenericInteger + CheckedAdd + CheckedMul + CheckedSub,
BigInt: GenericInteger + CheckedAdd + CheckedDiv + CheckedMul + CheckedSub + PartialOrd,
source§fn from(val: BigInt) -> GenericFraction<T>
fn from(val: BigInt) -> GenericFraction<T>
source§impl<T> From<BigUint> for GenericFraction<T>where
T: Clone + Integer + GenericInteger + CheckedAdd + CheckedMul + CheckedSub,
BigUint: GenericInteger + CheckedAdd + CheckedDiv + CheckedMul + CheckedSub + PartialOrd,
impl<T> From<BigUint> for GenericFraction<T>where
T: Clone + Integer + GenericInteger + CheckedAdd + CheckedMul + CheckedSub,
BigUint: GenericInteger + CheckedAdd + CheckedDiv + CheckedMul + CheckedSub + PartialOrd,
source§fn from(val: BigUint) -> GenericFraction<T>
fn from(val: BigUint) -> GenericFraction<T>
source§impl<T: Clone + FromPrimitive + Integer + CheckedAdd + CheckedMul + CheckedSub> From<f32> for GenericFraction<T>
impl<T: Clone + FromPrimitive + Integer + CheckedAdd + CheckedMul + CheckedSub> From<f32> for GenericFraction<T>
source§fn from(val: f32) -> GenericFraction<T>
fn from(val: f32) -> GenericFraction<T>
source§impl<T: Clone + FromPrimitive + Integer + CheckedAdd + CheckedMul + CheckedSub> From<f64> for GenericFraction<T>
impl<T: Clone + FromPrimitive + Integer + CheckedAdd + CheckedMul + CheckedSub> From<f64> for GenericFraction<T>
source§fn from(val: f64) -> GenericFraction<T>
fn from(val: f64) -> GenericFraction<T>
source§impl<T> From<i128> for GenericFraction<T>where
T: Clone + Integer + GenericInteger + CheckedAdd + CheckedMul + CheckedSub,
i128: GenericInteger + CheckedAdd + CheckedDiv + CheckedMul + CheckedSub + PartialOrd,
impl<T> From<i128> for GenericFraction<T>where
T: Clone + Integer + GenericInteger + CheckedAdd + CheckedMul + CheckedSub,
i128: GenericInteger + CheckedAdd + CheckedDiv + CheckedMul + CheckedSub + PartialOrd,
source§fn from(val: i128) -> GenericFraction<T>
fn from(val: i128) -> GenericFraction<T>
source§impl<T> From<i16> for GenericFraction<T>where
T: Clone + Integer + GenericInteger + CheckedAdd + CheckedMul + CheckedSub,
i16: GenericInteger + CheckedAdd + CheckedDiv + CheckedMul + CheckedSub + PartialOrd,
impl<T> From<i16> for GenericFraction<T>where
T: Clone + Integer + GenericInteger + CheckedAdd + CheckedMul + CheckedSub,
i16: GenericInteger + CheckedAdd + CheckedDiv + CheckedMul + CheckedSub + PartialOrd,
source§fn from(val: i16) -> GenericFraction<T>
fn from(val: i16) -> GenericFraction<T>
source§impl<T> From<i32> for GenericFraction<T>where
T: Clone + Integer + GenericInteger + CheckedAdd + CheckedMul + CheckedSub,
i32: GenericInteger + CheckedAdd + CheckedDiv + CheckedMul + CheckedSub + PartialOrd,
impl<T> From<i32> for GenericFraction<T>where
T: Clone + Integer + GenericInteger + CheckedAdd + CheckedMul + CheckedSub,
i32: GenericInteger + CheckedAdd + CheckedDiv + CheckedMul + CheckedSub + PartialOrd,
source§fn from(val: i32) -> GenericFraction<T>
fn from(val: i32) -> GenericFraction<T>
source§impl<T> From<i64> for GenericFraction<T>where
T: Clone + Integer + GenericInteger + CheckedAdd + CheckedMul + CheckedSub,
i64: GenericInteger + CheckedAdd + CheckedDiv + CheckedMul + CheckedSub + PartialOrd,
impl<T> From<i64> for GenericFraction<T>where
T: Clone + Integer + GenericInteger + CheckedAdd + CheckedMul + CheckedSub,
i64: GenericInteger + CheckedAdd + CheckedDiv + CheckedMul + CheckedSub + PartialOrd,
source§fn from(val: i64) -> GenericFraction<T>
fn from(val: i64) -> GenericFraction<T>
source§impl<T> From<i8> for GenericFraction<T>where
T: Clone + Integer + GenericInteger + CheckedAdd + CheckedMul + CheckedSub,
i8: GenericInteger + CheckedAdd + CheckedDiv + CheckedMul + CheckedSub + PartialOrd,
impl<T> From<i8> for GenericFraction<T>where
T: Clone + Integer + GenericInteger + CheckedAdd + CheckedMul + CheckedSub,
i8: GenericInteger + CheckedAdd + CheckedDiv + CheckedMul + CheckedSub + PartialOrd,
source§fn from(val: i8) -> GenericFraction<T>
fn from(val: i8) -> GenericFraction<T>
source§impl<T> From<isize> for GenericFraction<T>where
T: Clone + Integer + GenericInteger + CheckedAdd + CheckedMul + CheckedSub,
isize: GenericInteger + CheckedAdd + CheckedDiv + CheckedMul + CheckedSub + PartialOrd,
impl<T> From<isize> for GenericFraction<T>where
T: Clone + Integer + GenericInteger + CheckedAdd + CheckedMul + CheckedSub,
isize: GenericInteger + CheckedAdd + CheckedDiv + CheckedMul + CheckedSub + PartialOrd,
source§fn from(val: isize) -> GenericFraction<T>
fn from(val: isize) -> GenericFraction<T>
source§impl<T> From<u128> for GenericFraction<T>where
T: Clone + Integer + GenericInteger + CheckedAdd + CheckedMul + CheckedSub,
u128: GenericInteger + CheckedAdd + CheckedDiv + CheckedMul + CheckedSub + PartialOrd,
impl<T> From<u128> for GenericFraction<T>where
T: Clone + Integer + GenericInteger + CheckedAdd + CheckedMul + CheckedSub,
u128: GenericInteger + CheckedAdd + CheckedDiv + CheckedMul + CheckedSub + PartialOrd,
source§fn from(val: u128) -> GenericFraction<T>
fn from(val: u128) -> GenericFraction<T>
source§impl<T> From<u16> for GenericFraction<T>where
T: Clone + Integer + GenericInteger + CheckedAdd + CheckedMul + CheckedSub,
u16: GenericInteger + CheckedAdd + CheckedDiv + CheckedMul + CheckedSub + PartialOrd,
impl<T> From<u16> for GenericFraction<T>where
T: Clone + Integer + GenericInteger + CheckedAdd + CheckedMul + CheckedSub,
u16: GenericInteger + CheckedAdd + CheckedDiv + CheckedMul + CheckedSub + PartialOrd,
source§fn from(val: u16) -> GenericFraction<T>
fn from(val: u16) -> GenericFraction<T>
source§impl<T> From<u32> for GenericFraction<T>where
T: Clone + Integer + GenericInteger + CheckedAdd + CheckedMul + CheckedSub,
u32: GenericInteger + CheckedAdd + CheckedDiv + CheckedMul + CheckedSub + PartialOrd,
impl<T> From<u32> for GenericFraction<T>where
T: Clone + Integer + GenericInteger + CheckedAdd + CheckedMul + CheckedSub,
u32: GenericInteger + CheckedAdd + CheckedDiv + CheckedMul + CheckedSub + PartialOrd,
source§fn from(val: u32) -> GenericFraction<T>
fn from(val: u32) -> GenericFraction<T>
source§impl<T> From<u64> for GenericFraction<T>where
T: Clone + Integer + GenericInteger + CheckedAdd + CheckedMul + CheckedSub,
u64: GenericInteger + CheckedAdd + CheckedDiv + CheckedMul + CheckedSub + PartialOrd,
impl<T> From<u64> for GenericFraction<T>where
T: Clone + Integer + GenericInteger + CheckedAdd + CheckedMul + CheckedSub,
u64: GenericInteger + CheckedAdd + CheckedDiv + CheckedMul + CheckedSub + PartialOrd,
source§fn from(val: u64) -> GenericFraction<T>
fn from(val: u64) -> GenericFraction<T>
source§impl<T> From<u8> for GenericFraction<T>where
T: Clone + Integer + GenericInteger + CheckedAdd + CheckedMul + CheckedSub,
u8: GenericInteger + CheckedAdd + CheckedDiv + CheckedMul + CheckedSub + PartialOrd,
impl<T> From<u8> for GenericFraction<T>where
T: Clone + Integer + GenericInteger + CheckedAdd + CheckedMul + CheckedSub,
u8: GenericInteger + CheckedAdd + CheckedDiv + CheckedMul + CheckedSub + PartialOrd,
source§fn from(val: u8) -> GenericFraction<T>
fn from(val: u8) -> GenericFraction<T>
source§impl<T> From<usize> for GenericFraction<T>where
T: Clone + Integer + GenericInteger + CheckedAdd + CheckedMul + CheckedSub,
usize: GenericInteger + CheckedAdd + CheckedDiv + CheckedMul + CheckedSub + PartialOrd,
impl<T> From<usize> for GenericFraction<T>where
T: Clone + Integer + GenericInteger + CheckedAdd + CheckedMul + CheckedSub,
usize: GenericInteger + CheckedAdd + CheckedDiv + CheckedMul + CheckedSub + PartialOrd,
source§fn from(val: usize) -> GenericFraction<T>
fn from(val: usize) -> GenericFraction<T>
source§impl<T> FromStr for GenericFraction<T>
impl<T> FromStr for GenericFraction<T>
source§impl<'a, T, O> Mul<O> for &'a GenericFraction<T>
impl<'a, T, O> Mul<O> for &'a GenericFraction<T>
source§type Output = GenericFraction<T>
type Output = GenericFraction<T>
*
operator.source§fn mul(self, other: O) -> GenericFraction<T>
fn mul(self, other: O) -> GenericFraction<T>
*
operation. Read moresource§impl<T, O> Mul<O> for GenericFraction<T>
impl<T, O> Mul<O> for GenericFraction<T>
source§impl<'a, T> Mul for &'a GenericFraction<T>
impl<'a, T> Mul for &'a GenericFraction<T>
source§type Output = GenericFraction<T>
type Output = GenericFraction<T>
*
operator.source§fn mul(self, other: Self) -> GenericFraction<T>
fn mul(self, other: Self) -> GenericFraction<T>
*
operation. Read moresource§impl<'a, T> MulAssign<&'a GenericFraction<T>> for GenericFraction<T>
impl<'a, T> MulAssign<&'a GenericFraction<T>> for GenericFraction<T>
source§fn mul_assign(&mut self, other: &'a Self)
fn mul_assign(&mut self, other: &'a Self)
*=
operation. Read moresource§impl<T, O> MulAssign<O> for GenericFraction<T>
impl<T, O> MulAssign<O> for GenericFraction<T>
source§fn mul_assign(&mut self, other: O)
fn mul_assign(&mut self, other: O)
*=
operation. Read moresource§impl<T: Clone + Integer> Num for GenericFraction<T>
impl<T: Clone + Integer> Num for GenericFraction<T>
type FromStrRadixErr = ParseRatioError
source§fn from_str_radix(str: &str, radix: u32) -> Result<Self, Self::FromStrRadixErr>
fn from_str_radix(str: &str, radix: u32) -> Result<Self, Self::FromStrRadixErr>
2..=36
). Read moresource§impl<T: Clone + Integer> Ord for GenericFraction<T>
impl<T: Clone + Integer> Ord for GenericFraction<T>
source§impl<T: Clone + Integer> PartialOrd for GenericFraction<T>
impl<T: Clone + Integer> PartialOrd for GenericFraction<T>
source§impl<'a, T: 'a + Clone + Integer> Product<&'a GenericFraction<T>> for GenericFraction<T>
impl<'a, T: 'a + Clone + Integer> Product<&'a GenericFraction<T>> for GenericFraction<T>
source§impl<'a, T, O> Rem<O> for &'a GenericFraction<T>
impl<'a, T, O> Rem<O> for &'a GenericFraction<T>
source§type Output = GenericFraction<T>
type Output = GenericFraction<T>
%
operator.source§fn rem(self, other: O) -> GenericFraction<T>
fn rem(self, other: O) -> GenericFraction<T>
%
operation. Read moresource§impl<T, O> Rem<O> for GenericFraction<T>
impl<T, O> Rem<O> for GenericFraction<T>
source§impl<'a, T> Rem for &'a GenericFraction<T>
impl<'a, T> Rem for &'a GenericFraction<T>
source§type Output = GenericFraction<T>
type Output = GenericFraction<T>
%
operator.source§fn rem(self, other: Self) -> GenericFraction<T>
fn rem(self, other: Self) -> GenericFraction<T>
%
operation. Read moresource§impl<'a, T> RemAssign<&'a GenericFraction<T>> for GenericFraction<T>
impl<'a, T> RemAssign<&'a GenericFraction<T>> for GenericFraction<T>
source§fn rem_assign(&mut self, other: &'a Self)
fn rem_assign(&mut self, other: &'a Self)
%=
operation. Read moresource§impl<T, O> RemAssign<O> for GenericFraction<T>
impl<T, O> RemAssign<O> for GenericFraction<T>
source§fn rem_assign(&mut self, other: O)
fn rem_assign(&mut self, other: O)
%=
operation. Read moresource§impl<T: Clone + Integer> Signed for GenericFraction<T>
impl<T: Clone + Integer> Signed for GenericFraction<T>
source§fn is_positive(&self) -> bool
fn is_positive(&self) -> bool
source§fn is_negative(&self) -> bool
fn is_negative(&self) -> bool
source§impl<'a, T, O> Sub<O> for &'a GenericFraction<T>
impl<'a, T, O> Sub<O> for &'a GenericFraction<T>
source§type Output = GenericFraction<T>
type Output = GenericFraction<T>
-
operator.source§fn sub(self, other: O) -> GenericFraction<T>
fn sub(self, other: O) -> GenericFraction<T>
-
operation. Read moresource§impl<T, O> Sub<O> for GenericFraction<T>
impl<T, O> Sub<O> for GenericFraction<T>
source§impl<'a, T> Sub for &'a GenericFraction<T>
impl<'a, T> Sub for &'a GenericFraction<T>
source§type Output = GenericFraction<T>
type Output = GenericFraction<T>
-
operator.source§fn sub(self, other: Self) -> GenericFraction<T>
fn sub(self, other: Self) -> GenericFraction<T>
-
operation. Read moresource§impl<'a, T> SubAssign<&'a GenericFraction<T>> for GenericFraction<T>
impl<'a, T> SubAssign<&'a GenericFraction<T>> for GenericFraction<T>
source§fn sub_assign(&mut self, other: &'a Self)
fn sub_assign(&mut self, other: &'a Self)
-=
operation. Read moresource§impl<T, O> SubAssign<O> for GenericFraction<T>
impl<T, O> SubAssign<O> for GenericFraction<T>
source§fn sub_assign(&mut self, other: O)
fn sub_assign(&mut self, other: O)
-=
operation. Read moresource§impl<'a, T: 'a + Clone + Integer> Sum<&'a GenericFraction<T>> for GenericFraction<T>
impl<'a, T: 'a + Clone + Integer> Sum<&'a GenericFraction<T>> for GenericFraction<T>
source§impl<T: Clone + Integer + PartialEq + ToPrimitive> ToPrimitive for GenericFraction<T>
impl<T: Clone + Integer + PartialEq + ToPrimitive> ToPrimitive for GenericFraction<T>
source§fn to_i64(&self) -> Option<i64>
fn to_i64(&self) -> Option<i64>
self
to an i64
. If the value cannot be
represented by an i64
, then None
is returned.source§fn to_u64(&self) -> Option<u64>
fn to_u64(&self) -> Option<u64>
self
to a u64
. If the value cannot be
represented by a u64
, then None
is returned.source§fn to_f64(&self) -> Option<f64>
fn to_f64(&self) -> Option<f64>
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 moresource§fn to_isize(&self) -> Option<isize>
fn to_isize(&self) -> Option<isize>
self
to an isize
. If the value cannot be
represented by an isize
, then None
is returned.source§fn to_i8(&self) -> Option<i8>
fn to_i8(&self) -> Option<i8>
self
to an i8
. If the value cannot be
represented by an i8
, then None
is returned.source§fn to_i16(&self) -> Option<i16>
fn to_i16(&self) -> Option<i16>
self
to an i16
. If the value cannot be
represented by an i16
, then None
is returned.source§fn to_i32(&self) -> Option<i32>
fn to_i32(&self) -> Option<i32>
self
to an i32
. If the value cannot be
represented by an i32
, then None
is returned.source§fn to_i128(&self) -> Option<i128>
fn to_i128(&self) -> Option<i128>
self
to an i128
. If the value cannot be
represented by an i128
(i64
under the default implementation), then
None
is returned. Read moresource§fn to_usize(&self) -> Option<usize>
fn to_usize(&self) -> Option<usize>
self
to a usize
. If the value cannot be
represented by a usize
, then None
is returned.source§fn to_u8(&self) -> Option<u8>
fn to_u8(&self) -> Option<u8>
self
to a u8
. If the value cannot be
represented by a u8
, then None
is returned.source§fn to_u16(&self) -> Option<u16>
fn to_u16(&self) -> Option<u16>
self
to a u16
. If the value cannot be
represented by a u16
, then None
is returned.source§fn to_u32(&self) -> Option<u32>
fn to_u32(&self) -> Option<u32>
self
to a u32
. If the value cannot be
represented by a u32
, then None
is returned.source§impl<T> TryFrom<GenericFraction<T>> for BigIntwhere
T: Clone + GenericInteger,
impl<T> TryFrom<GenericFraction<T>> for BigIntwhere
T: Clone + GenericInteger,
source§impl<T> TryFrom<GenericFraction<T>> for BigUintwhere
T: Clone + GenericInteger,
impl<T> TryFrom<GenericFraction<T>> for BigUintwhere
T: Clone + GenericInteger,
source§impl<T> TryFrom<GenericFraction<T>> for f32where
T: Clone + GenericInteger,
impl<T> TryFrom<GenericFraction<T>> for f32where
T: Clone + GenericInteger,
source§impl<T> TryFrom<GenericFraction<T>> for f64where
T: Clone + GenericInteger,
impl<T> TryFrom<GenericFraction<T>> for f64where
T: Clone + GenericInteger,
source§impl<T> TryFrom<GenericFraction<T>> for i128where
T: Clone + GenericInteger,
impl<T> TryFrom<GenericFraction<T>> for i128where
T: Clone + GenericInteger,
source§impl<T> TryFrom<GenericFraction<T>> for i16where
T: Clone + GenericInteger,
impl<T> TryFrom<GenericFraction<T>> for i16where
T: Clone + GenericInteger,
source§impl<T> TryFrom<GenericFraction<T>> for i32where
T: Clone + GenericInteger,
impl<T> TryFrom<GenericFraction<T>> for i32where
T: Clone + GenericInteger,
source§impl<T> TryFrom<GenericFraction<T>> for i64where
T: Clone + GenericInteger,
impl<T> TryFrom<GenericFraction<T>> for i64where
T: Clone + GenericInteger,
source§impl<T> TryFrom<GenericFraction<T>> for i8where
T: Clone + GenericInteger,
impl<T> TryFrom<GenericFraction<T>> for i8where
T: Clone + GenericInteger,
source§impl<T> TryFrom<GenericFraction<T>> for isizewhere
T: Clone + GenericInteger,
impl<T> TryFrom<GenericFraction<T>> for isizewhere
T: Clone + GenericInteger,
source§impl<T> TryFrom<GenericFraction<T>> for u128where
T: Clone + GenericInteger,
impl<T> TryFrom<GenericFraction<T>> for u128where
T: Clone + GenericInteger,
source§impl<T> TryFrom<GenericFraction<T>> for u16where
T: Clone + GenericInteger,
impl<T> TryFrom<GenericFraction<T>> for u16where
T: Clone + GenericInteger,
source§impl<T> TryFrom<GenericFraction<T>> for u32where
T: Clone + GenericInteger,
impl<T> TryFrom<GenericFraction<T>> for u32where
T: Clone + GenericInteger,
source§impl<T> TryFrom<GenericFraction<T>> for u64where
T: Clone + GenericInteger,
impl<T> TryFrom<GenericFraction<T>> for u64where
T: Clone + GenericInteger,
source§impl<T> TryFrom<GenericFraction<T>> for u8where
T: Clone + GenericInteger,
impl<T> TryFrom<GenericFraction<T>> for u8where
T: Clone + GenericInteger,
source§impl<T> TryFrom<GenericFraction<T>> for usizewhere
T: Clone + GenericInteger,
impl<T> TryFrom<GenericFraction<T>> for usizewhere
T: Clone + GenericInteger,
source§impl<T, F> TryToConvertFrom<GenericFraction<F>> for GenericFraction<T>
impl<T, F> TryToConvertFrom<GenericFraction<F>> for GenericFraction<T>
fn try_to_convert_from(src: GenericFraction<F>) -> Option<Self>
impl<T> Copy for GenericFraction<T>
Copy semantics to be applied for the target type, but only if T also has it.
impl<T: Clone + Integer> Eq for GenericFraction<T>
Auto Trait Implementations§
impl<T> Freeze for GenericFraction<T>where
T: Freeze,
impl<T> RefUnwindSafe for GenericFraction<T>where
T: RefUnwindSafe,
impl<T> Send for GenericFraction<T>where
T: Send,
impl<T> Sync for GenericFraction<T>where
T: Sync,
impl<T> Unpin for GenericFraction<T>where
T: Unpin,
impl<T> UnwindSafe for GenericFraction<T>where
T: UnwindSafe,
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)