[−][src]Enum fraction::prelude::GenericFraction
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
Infinity(Sign)
Implementations
impl<T> GenericFraction<T> where
T: Clone + Integer,
[src]
T: Clone + Integer,
pub fn new_generic<N, D>(
sign: Sign,
num: N,
den: D
) -> Option<GenericFraction<T>> where
N: GenericInteger + PartialOrd,
D: GenericInteger + PartialOrd,
T: GenericInteger,
[src]
sign: Sign,
num: N,
den: D
) -> Option<GenericFraction<T>> where
N: GenericInteger + PartialOrd,
D: GenericInteger + PartialOrd,
T: GenericInteger,
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));
pub fn new<N, D>(num: N, den: D) -> GenericFraction<T> where
N: Into<T>,
D: Into<T>,
[src]
N: Into<T>,
D: Into<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);
pub fn new_neg<N, D>(num: N, den: D) -> GenericFraction<T> where
N: Into<T>,
D: Into<T>,
[src]
N: Into<T>,
D: Into<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);
pub fn new_raw(num: T, den: T) -> GenericFraction<T>
[src]
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);
pub fn new_raw_neg(num: T, den: T) -> GenericFraction<T>
[src]
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);
pub fn numer(&self) -> Option<&T>
[src]
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 ());
pub fn denom(&self) -> Option<&T>
[src]
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 ());
pub fn sign(&self) -> Option<Sign>
[src]
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 ());
pub fn from_fraction<F>(from: GenericFraction<F>) -> GenericFraction<T> where
T: From<F>,
F: Clone + Integer,
[src]
T: From<F>,
F: Clone + Integer,
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));
pub fn into_fraction<I>(self) -> GenericFraction<I> where
T: Into<I>,
I: Clone + Integer,
[src]
T: Into<I>,
I: Clone + Integer,
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());
pub fn format_as_decimal(&self, precision: usize) -> Option<String> where
T: Clone + GenericInteger,
[src]
T: Clone + GenericInteger,
Use format!("{:.1$}", fraction, precision)
Returns a decimal representation of the fraction
DEPRECATED! Use format!("{:.1$}", fraction, precision)
instead
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");
pub fn from_decimal_str(src: &str) -> Result<Self, ParseError> where
T: CheckedAdd + CheckedMul,
[src]
T: CheckedAdd + CheckedMul,
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]
pub fn nan() -> Self
[src]
Returns NaN value
Examples
use fraction::GenericFraction; type F = GenericFraction<u8>; assert_eq! (F::nan (), F::new (0, 0));
pub fn infinity() -> Self
[src]
Returns positive Infinity value
Examples
use fraction::GenericFraction; type F = GenericFraction<u8>; assert_eq! (F::infinity (), F::new (1, 0));
pub fn neg_infinity() -> Self
[src]
Returns negative Infinity value
Examples
use fraction::GenericFraction; type F = GenericFraction<u8>; assert_eq! (F::neg_infinity (), F::new_neg (1, 0));
pub fn neg_zero() -> Self
[src]
Returns zero with negative sign
Examples
use fraction::GenericFraction; type F = GenericFraction<u8>; assert_eq! (F::neg_zero (), F::new_neg (0, 1));
pub fn min_positive_value() -> Self where
T: Bounded,
[src]
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));
pub fn is_nan(&self) -> bool
[src]
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 ());
pub fn is_infinite(&self) -> bool
[src]
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 ());
pub fn is_finite(&self) -> bool
[src]
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 ());
pub fn is_normal(&self) -> bool
[src]
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 ());
pub fn classify(&self) -> FpCategory
[src]
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);
pub fn floor(&self) -> Self
[src]
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));
pub fn ceil(&self) -> Self
[src]
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));
pub fn round(&self) -> Self
[src]
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));
pub fn trunc(&self) -> Self
[src]
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));
pub fn fract(&self) -> Self
[src]
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));
pub fn abs(&self) -> Self
[src]
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));
pub fn signum(&self) -> Self
[src]
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 ());
pub fn is_sign_positive(&self) -> bool
[src]
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 ());
pub fn is_sign_negative(&self) -> bool
[src]
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 ());
pub fn mul_add(&self, a: Self, b: Self) -> Self
[src]
self.clone () * a + b
Added for interface compatibility with float types
pub fn recip(&self) -> Self
[src]
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<'a, T> Add<&'a GenericFraction<T>> for &'a GenericFraction<T> where
T: Clone + Integer,
[src]
T: Clone + Integer,
type Output = GenericFraction<T>
The resulting type after applying the +
operator.
pub fn add(self, other: Self) -> GenericFraction<T>
[src]
impl<T: Clone + Integer> Add<GenericFraction<T>> for GenericFraction<T>
[src]
type Output = Self
The resulting type after applying the +
operator.
pub fn add(self, other: Self) -> Self
[src]
impl<'a, T> AddAssign<&'a GenericFraction<T>> for GenericFraction<T> where
T: Clone + Integer,
[src]
T: Clone + Integer,
pub fn add_assign(&mut self, other: &'a Self)
[src]
impl<T: Clone + Integer> AddAssign<GenericFraction<T>> for GenericFraction<T>
[src]
pub fn add_assign(&mut self, other: Self)
[src]
impl<T: Bounded + Clone + Integer> Bounded for GenericFraction<T>
[src]
impl<T> CheckedAdd for GenericFraction<T> where
T: Clone + Integer + CheckedAdd + CheckedSub + CheckedMul,
[src]
T: Clone + Integer + CheckedAdd + CheckedSub + CheckedMul,
pub fn checked_add(&self, other: &Self) -> Option<GenericFraction<T>>
[src]
impl<T> CheckedDiv for GenericFraction<T> where
T: Clone + Integer + CheckedDiv + CheckedMul,
[src]
T: Clone + Integer + CheckedDiv + CheckedMul,
pub fn checked_div(&self, other: &Self) -> Option<GenericFraction<T>>
[src]
impl<T> CheckedMul for GenericFraction<T> where
T: Clone + Integer + CheckedMul,
[src]
T: Clone + Integer + CheckedMul,
pub fn checked_mul(&self, other: &Self) -> Option<GenericFraction<T>>
[src]
impl<T> CheckedSub for GenericFraction<T> where
T: Clone + Integer + CheckedAdd + CheckedSub + CheckedMul,
[src]
T: Clone + Integer + CheckedAdd + CheckedSub + CheckedMul,
pub fn checked_sub(&self, other: &Self) -> Option<GenericFraction<T>>
[src]
impl<T: Clone> Clone for GenericFraction<T> where
T: Clone + Integer,
[src]
T: Clone + Integer,
pub fn clone(&self) -> GenericFraction<T>
[src]
pub fn clone_from(&mut self, source: &Self)
1.0.0[src]
impl<T> Copy for GenericFraction<T> where
T: Copy + Integer,
[src]
T: Copy + Integer,
Copy semantics to be applied for the target type, but only if T also has it.
impl<T: Debug> Debug for GenericFraction<T> where
T: Clone + Integer,
[src]
T: Clone + Integer,
impl<'de, T> Deserialize<'de> for GenericFraction<T> where
T: Clone + Integer,
T: Deserialize<'de>,
[src]
T: Clone + Integer,
T: Deserialize<'de>,
pub fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error> where
__D: Deserializer<'de>,
[src]
__D: Deserializer<'de>,
impl<T: Clone + GenericInteger> Display for GenericFraction<T>
[src]
impl<'a, T> Div<&'a GenericFraction<T>> for &'a GenericFraction<T> where
T: Clone + Integer,
[src]
T: Clone + Integer,
type Output = GenericFraction<T>
The resulting type after applying the /
operator.
pub fn div(self, other: Self) -> GenericFraction<T>
[src]
impl<T: Clone + Integer> Div<GenericFraction<T>> for GenericFraction<T>
[src]
type Output = Self
The resulting type after applying the /
operator.
pub fn div(self, other: Self) -> Self
[src]
impl<'a, T> DivAssign<&'a GenericFraction<T>> for GenericFraction<T> where
T: Clone + Integer,
[src]
T: Clone + Integer,
pub fn div_assign(&mut self, other: &'a Self)
[src]
impl<T: Clone + Integer> DivAssign<GenericFraction<T>> for GenericFraction<T>
[src]
pub fn div_assign(&mut self, other: Self)
[src]
impl<T: Clone + Integer> Eq for GenericFraction<T>
[src]
impl<T, N, D> From<(N, D)> for GenericFraction<T> where
T: Clone + Integer,
N: Display,
D: Display,
[src]
T: Clone + Integer,
N: Display,
D: Display,
pub fn from(pair: (N, D)) -> GenericFraction<T>
[src]
impl<T> From<BigInt> for GenericFraction<T> where
T: Clone + Integer + GenericInteger + CheckedAdd + CheckedMul + CheckedSub,
BigInt: GenericInteger + CheckedAdd + CheckedDiv + CheckedMul + CheckedSub + PartialOrd,
[src]
T: Clone + Integer + GenericInteger + CheckedAdd + CheckedMul + CheckedSub,
BigInt: GenericInteger + CheckedAdd + CheckedDiv + CheckedMul + CheckedSub + PartialOrd,
pub fn from(val: BigInt) -> GenericFraction<T>
[src]
impl<T> From<BigUint> for GenericFraction<T> where
T: Clone + Integer + GenericInteger + CheckedAdd + CheckedMul + CheckedSub,
BigUint: GenericInteger + CheckedAdd + CheckedDiv + CheckedMul + CheckedSub + PartialOrd,
[src]
T: Clone + Integer + GenericInteger + CheckedAdd + CheckedMul + CheckedSub,
BigUint: GenericInteger + CheckedAdd + CheckedDiv + CheckedMul + CheckedSub + PartialOrd,
pub fn from(val: BigUint) -> GenericFraction<T>
[src]
impl<T: Clone + FromPrimitive + Integer + CheckedAdd + CheckedMul + CheckedSub> From<f32> for GenericFraction<T>
[src]
pub fn from(val: f32) -> GenericFraction<T>
[src]
impl<T: Clone + FromPrimitive + Integer + CheckedAdd + CheckedMul + CheckedSub> From<f64> for GenericFraction<T>
[src]
pub fn from(val: f64) -> GenericFraction<T>
[src]
impl<T> From<i128> for GenericFraction<T> where
T: Clone + Integer + GenericInteger + CheckedAdd + CheckedMul + CheckedSub,
i128: GenericInteger + CheckedAdd + CheckedDiv + CheckedMul + CheckedSub + PartialOrd,
[src]
T: Clone + Integer + GenericInteger + CheckedAdd + CheckedMul + CheckedSub,
i128: GenericInteger + CheckedAdd + CheckedDiv + CheckedMul + CheckedSub + PartialOrd,
pub fn from(val: i128) -> GenericFraction<T>
[src]
impl<T> From<i16> for GenericFraction<T> where
T: Clone + Integer + GenericInteger + CheckedAdd + CheckedMul + CheckedSub,
i16: GenericInteger + CheckedAdd + CheckedDiv + CheckedMul + CheckedSub + PartialOrd,
[src]
T: Clone + Integer + GenericInteger + CheckedAdd + CheckedMul + CheckedSub,
i16: GenericInteger + CheckedAdd + CheckedDiv + CheckedMul + CheckedSub + PartialOrd,
pub fn from(val: i16) -> GenericFraction<T>
[src]
impl<T> From<i32> for GenericFraction<T> where
T: Clone + Integer + GenericInteger + CheckedAdd + CheckedMul + CheckedSub,
i32: GenericInteger + CheckedAdd + CheckedDiv + CheckedMul + CheckedSub + PartialOrd,
[src]
T: Clone + Integer + GenericInteger + CheckedAdd + CheckedMul + CheckedSub,
i32: GenericInteger + CheckedAdd + CheckedDiv + CheckedMul + CheckedSub + PartialOrd,
pub fn from(val: i32) -> GenericFraction<T>
[src]
impl<T> From<i64> for GenericFraction<T> where
T: Clone + Integer + GenericInteger + CheckedAdd + CheckedMul + CheckedSub,
i64: GenericInteger + CheckedAdd + CheckedDiv + CheckedMul + CheckedSub + PartialOrd,
[src]
T: Clone + Integer + GenericInteger + CheckedAdd + CheckedMul + CheckedSub,
i64: GenericInteger + CheckedAdd + CheckedDiv + CheckedMul + CheckedSub + PartialOrd,
pub fn from(val: i64) -> GenericFraction<T>
[src]
impl<T> From<i8> for GenericFraction<T> where
T: Clone + Integer + GenericInteger + CheckedAdd + CheckedMul + CheckedSub,
i8: GenericInteger + CheckedAdd + CheckedDiv + CheckedMul + CheckedSub + PartialOrd,
[src]
T: Clone + Integer + GenericInteger + CheckedAdd + CheckedMul + CheckedSub,
i8: GenericInteger + CheckedAdd + CheckedDiv + CheckedMul + CheckedSub + PartialOrd,
pub fn from(val: i8) -> GenericFraction<T>
[src]
impl<T> From<isize> for GenericFraction<T> where
T: Clone + Integer + GenericInteger + CheckedAdd + CheckedMul + CheckedSub,
isize: GenericInteger + CheckedAdd + CheckedDiv + CheckedMul + CheckedSub + PartialOrd,
[src]
T: Clone + Integer + GenericInteger + CheckedAdd + CheckedMul + CheckedSub,
isize: GenericInteger + CheckedAdd + CheckedDiv + CheckedMul + CheckedSub + PartialOrd,
pub fn from(val: isize) -> GenericFraction<T>
[src]
impl<T> From<u128> for GenericFraction<T> where
T: Clone + Integer + GenericInteger + CheckedAdd + CheckedMul + CheckedSub,
u128: GenericInteger + CheckedAdd + CheckedDiv + CheckedMul + CheckedSub + PartialOrd,
[src]
T: Clone + Integer + GenericInteger + CheckedAdd + CheckedMul + CheckedSub,
u128: GenericInteger + CheckedAdd + CheckedDiv + CheckedMul + CheckedSub + PartialOrd,
pub fn from(val: u128) -> GenericFraction<T>
[src]
impl<T> From<u16> for GenericFraction<T> where
T: Clone + Integer + GenericInteger + CheckedAdd + CheckedMul + CheckedSub,
u16: GenericInteger + CheckedAdd + CheckedDiv + CheckedMul + CheckedSub + PartialOrd,
[src]
T: Clone + Integer + GenericInteger + CheckedAdd + CheckedMul + CheckedSub,
u16: GenericInteger + CheckedAdd + CheckedDiv + CheckedMul + CheckedSub + PartialOrd,
pub fn from(val: u16) -> GenericFraction<T>
[src]
impl<T> From<u32> for GenericFraction<T> where
T: Clone + Integer + GenericInteger + CheckedAdd + CheckedMul + CheckedSub,
u32: GenericInteger + CheckedAdd + CheckedDiv + CheckedMul + CheckedSub + PartialOrd,
[src]
T: Clone + Integer + GenericInteger + CheckedAdd + CheckedMul + CheckedSub,
u32: GenericInteger + CheckedAdd + CheckedDiv + CheckedMul + CheckedSub + PartialOrd,
pub fn from(val: u32) -> GenericFraction<T>
[src]
impl<T> From<u64> for GenericFraction<T> where
T: Clone + Integer + GenericInteger + CheckedAdd + CheckedMul + CheckedSub,
u64: GenericInteger + CheckedAdd + CheckedDiv + CheckedMul + CheckedSub + PartialOrd,
[src]
T: Clone + Integer + GenericInteger + CheckedAdd + CheckedMul + CheckedSub,
u64: GenericInteger + CheckedAdd + CheckedDiv + CheckedMul + CheckedSub + PartialOrd,
pub fn from(val: u64) -> GenericFraction<T>
[src]
impl<T> From<u8> for GenericFraction<T> where
T: Clone + Integer + GenericInteger + CheckedAdd + CheckedMul + CheckedSub,
u8: GenericInteger + CheckedAdd + CheckedDiv + CheckedMul + CheckedSub + PartialOrd,
[src]
T: Clone + Integer + GenericInteger + CheckedAdd + CheckedMul + CheckedSub,
u8: GenericInteger + CheckedAdd + CheckedDiv + CheckedMul + CheckedSub + PartialOrd,
pub fn from(val: u8) -> GenericFraction<T>
[src]
impl<T> From<usize> for GenericFraction<T> where
T: Clone + Integer + GenericInteger + CheckedAdd + CheckedMul + CheckedSub,
usize: GenericInteger + CheckedAdd + CheckedDiv + CheckedMul + CheckedSub + PartialOrd,
[src]
T: Clone + Integer + GenericInteger + CheckedAdd + CheckedMul + CheckedSub,
usize: GenericInteger + CheckedAdd + CheckedDiv + CheckedMul + CheckedSub + PartialOrd,
pub fn from(val: usize) -> GenericFraction<T>
[src]
impl<S, T> FromInputValue<S> for GenericFraction<T> where
S: ScalarValue,
&'a S: ScalarRefValue<'a>,
T: Clone + Integer + CheckedAdd + CheckedMul + CheckedSub + Num + One,
[src]
S: ScalarValue,
&'a S: ScalarRefValue<'a>,
T: Clone + Integer + CheckedAdd + CheckedMul + CheckedSub + Num + One,
pub fn from_input_value(value: &InputValue<S>) -> Option<Self>
[src]
impl<T> FromSql for GenericFraction<T> where
T: Clone + GenericInteger + From<u16>,
[src]
T: Clone + GenericInteger + From<u16>,
pub fn from_sql(
_ty: &Type,
raw: &[u8]
) -> Result<Self, Box<dyn Error + Sync + Send>>
[src]
_ty: &Type,
raw: &[u8]
) -> Result<Self, Box<dyn Error + Sync + Send>>
pub fn accepts(ty: &Type) -> bool
[src]
pub fn from_sql_null(
ty: &Type
) -> Result<Self, Box<dyn Error + 'static + Send + Sync, Global>>
ty: &Type
) -> Result<Self, Box<dyn Error + 'static + Send + Sync, Global>>
pub fn from_sql_nullable(
ty: &Type,
raw: Option<&[u8]>
) -> Result<Self, Box<dyn Error + 'static + Send + Sync, Global>>
ty: &Type,
raw: Option<&[u8]>
) -> Result<Self, Box<dyn Error + 'static + Send + Sync, Global>>
impl<S, T> GraphQLType<S> for GenericFraction<T> where
S: ScalarValue,
&'a S: ScalarRefValue<'a>,
T: Clone + GenericInteger + Display + 'static,
[src]
S: ScalarValue,
&'a S: ScalarRefValue<'a>,
T: Clone + GenericInteger + Display + 'static,
type Context = ()
The expected context type for this GraphQL type Read more
type TypeInfo = ()
Type that may carry additional schema information Read more
pub fn name(_: &()) -> Option<&str>
[src]
pub fn meta<'r>(info: &(), registry: &mut Registry<'r, S>) -> MetaType<'r, S> where
S: 'r,
[src]
S: 'r,
pub fn resolve(
&self,
_: &(),
_: Option<&[Selection<'_, S>]>,
_: &Executor<'_, Self::Context, S>
) -> Value<S>
[src]
&self,
_: &(),
_: Option<&[Selection<'_, S>]>,
_: &Executor<'_, Self::Context, S>
) -> Value<S>
pub fn resolve_field(
&self,
info: &Self::TypeInfo,
field_name: &str,
arguments: &Arguments<'_, S>,
executor: &Executor<'_, Self::Context, S>
) -> Result<Value<S>, FieldError<S>>
[src]
&self,
info: &Self::TypeInfo,
field_name: &str,
arguments: &Arguments<'_, S>,
executor: &Executor<'_, Self::Context, S>
) -> Result<Value<S>, FieldError<S>>
pub fn resolve_into_type(
&self,
info: &Self::TypeInfo,
type_name: &str,
selection_set: Option<&[Selection<'_, S>]>,
executor: &Executor<'_, Self::Context, S>
) -> Result<Value<S>, FieldError<S>>
[src]
&self,
info: &Self::TypeInfo,
type_name: &str,
selection_set: Option<&[Selection<'_, S>]>,
executor: &Executor<'_, Self::Context, S>
) -> Result<Value<S>, FieldError<S>>
pub fn concrete_type_name(
&self,
context: &Self::Context,
info: &Self::TypeInfo
) -> String
[src]
&self,
context: &Self::Context,
info: &Self::TypeInfo
) -> String
impl<T: Clone + Integer + Hash> Hash for GenericFraction<T>
[src]
pub fn hash<H: Hasher>(&self, state: &mut H)
[src]
pub fn hash_slice<H>(data: &[Self], state: &mut H) where
H: Hasher,
1.3.0[src]
H: Hasher,
impl<'a, T> Mul<&'a GenericFraction<T>> for &'a GenericFraction<T> where
T: Clone + Integer,
[src]
T: Clone + Integer,
type Output = GenericFraction<T>
The resulting type after applying the *
operator.
pub fn mul(self, other: Self) -> GenericFraction<T>
[src]
impl<T: Clone + Integer> Mul<GenericFraction<T>> for GenericFraction<T>
[src]
type Output = Self
The resulting type after applying the *
operator.
pub fn mul(self, other: Self) -> Self
[src]
impl<'a, T> MulAssign<&'a GenericFraction<T>> for GenericFraction<T> where
T: Clone + Integer,
[src]
T: Clone + Integer,
pub fn mul_assign(&mut self, other: &'a Self)
[src]
impl<T: Clone + Integer> MulAssign<GenericFraction<T>> for GenericFraction<T>
[src]
pub fn mul_assign(&mut self, other: Self)
[src]
impl<T: Clone + Integer> Neg for GenericFraction<T>
[src]
type Output = GenericFraction<T>
The resulting type after applying the -
operator.
pub fn neg(self) -> Self
[src]
impl<'a, T: Clone + Integer> Neg for &'a GenericFraction<T>
[src]
type Output = GenericFraction<T>
The resulting type after applying the -
operator.
pub fn neg(self) -> Self::Output
[src]
impl<T: Clone + Integer> Num for GenericFraction<T>
[src]
type FromStrRadixErr = ParseRatioError
pub fn from_str_radix(
str: &str,
radix: u32
) -> Result<Self, Self::FromStrRadixErr>
[src]
str: &str,
radix: u32
) -> Result<Self, Self::FromStrRadixErr>
impl<T: Clone + Integer> One for GenericFraction<T>
[src]
pub fn one() -> Self
[src]
pub fn set_one(&mut self)
[src]
pub fn is_one(&self) -> bool where
Self: PartialEq<Self>,
[src]
Self: PartialEq<Self>,
impl<S, T> ParseScalarValue<S> for GenericFraction<T> where
S: ScalarValue,
&'a S: ScalarRefValue<'a>,
T: Clone + Integer + CheckedAdd + CheckedMul + CheckedSub + Display,
[src]
S: ScalarValue,
&'a S: ScalarRefValue<'a>,
T: Clone + Integer + CheckedAdd + CheckedMul + CheckedSub + Display,
pub fn from_str<'a>(value: ScalarToken<'a>) -> ParseScalarResult<'a, S>
[src]
impl<T: Clone + Integer> PartialEq<GenericFraction<T>> for GenericFraction<T>
[src]
pub fn eq(&self, other: &Self) -> bool
[src]
#[must_use]pub fn ne(&self, other: &Rhs) -> bool
1.0.0[src]
impl<T: Clone + Integer> PartialOrd<GenericFraction<T>> for GenericFraction<T>
[src]
pub fn partial_cmp(&self, other: &Self) -> Option<Ordering>
[src]
#[must_use]pub fn lt(&self, other: &Rhs) -> bool
1.0.0[src]
#[must_use]pub fn le(&self, other: &Rhs) -> bool
1.0.0[src]
#[must_use]pub fn gt(&self, other: &Rhs) -> bool
1.0.0[src]
#[must_use]pub fn ge(&self, other: &Rhs) -> bool
1.0.0[src]
impl<'a, T: 'a + Clone + Integer> Product<&'a GenericFraction<T>> for GenericFraction<T>
[src]
impl<T: Clone + Integer> Product<GenericFraction<T>> for GenericFraction<T>
[src]
impl<'a, T> Rem<&'a GenericFraction<T>> for &'a GenericFraction<T> where
T: Clone + Integer,
[src]
T: Clone + Integer,
type Output = GenericFraction<T>
The resulting type after applying the %
operator.
pub fn rem(self, other: Self) -> GenericFraction<T>
[src]
impl<T: Clone + Integer> Rem<GenericFraction<T>> for GenericFraction<T>
[src]
type Output = Self
The resulting type after applying the %
operator.
pub fn rem(self, other: Self) -> Self
[src]
impl<'a, T> RemAssign<&'a GenericFraction<T>> for GenericFraction<T> where
T: Clone + Integer,
[src]
T: Clone + Integer,
pub fn rem_assign(&mut self, other: &'a Self)
[src]
impl<T: Clone + Integer> RemAssign<GenericFraction<T>> for GenericFraction<T>
[src]
pub fn rem_assign(&mut self, other: Self)
[src]
impl<T> Serialize for GenericFraction<T> where
T: Clone + Integer,
T: Serialize,
[src]
T: Clone + Integer,
T: Serialize,
pub fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error> where
__S: Serializer,
[src]
__S: Serializer,
impl<T: Clone + Integer> Signed for GenericFraction<T>
[src]
pub fn abs(&self) -> Self
[src]
pub fn abs_sub(&self, other: &Self) -> Self
[src]
pub fn signum(&self) -> Self
[src]
pub fn is_positive(&self) -> bool
[src]
pub fn is_negative(&self) -> bool
[src]
impl<'a, T> Sub<&'a GenericFraction<T>> for &'a GenericFraction<T> where
T: Clone + Integer,
[src]
T: Clone + Integer,
type Output = GenericFraction<T>
The resulting type after applying the -
operator.
pub fn sub(self, other: Self) -> GenericFraction<T>
[src]
impl<T: Clone + Integer> Sub<GenericFraction<T>> for GenericFraction<T>
[src]
type Output = Self
The resulting type after applying the -
operator.
pub fn sub(self, other: Self) -> Self
[src]
impl<'a, T> SubAssign<&'a GenericFraction<T>> for GenericFraction<T> where
T: Clone + Integer,
[src]
T: Clone + Integer,
pub fn sub_assign(&mut self, other: &'a Self)
[src]
impl<T: Clone + Integer> SubAssign<GenericFraction<T>> for GenericFraction<T>
[src]
pub fn sub_assign(&mut self, other: Self)
[src]
impl<'a, T: 'a + Clone + Integer> Sum<&'a GenericFraction<T>> for GenericFraction<T>
[src]
impl<T: Clone + Integer> Sum<GenericFraction<T>> for GenericFraction<T>
[src]
impl<S, T> ToInputValue<S> for GenericFraction<T> where
S: ScalarValue,
&'a S: ScalarRefValue<'a>,
T: Clone + GenericInteger,
[src]
S: ScalarValue,
&'a S: ScalarRefValue<'a>,
T: Clone + GenericInteger,
pub fn to_input_value(&self) -> InputValue<S>
[src]
impl<T: Clone + Integer + PartialEq + ToPrimitive> ToPrimitive for GenericFraction<T>
[src]
pub fn to_i64(&self) -> Option<i64>
[src]
pub fn to_u64(&self) -> Option<u64>
[src]
pub fn to_f64(&self) -> Option<f64>
[src]
pub fn to_isize(&self) -> Option<isize>
[src]
pub fn to_i8(&self) -> Option<i8>
[src]
pub fn to_i16(&self) -> Option<i16>
[src]
pub fn to_i32(&self) -> Option<i32>
[src]
pub fn to_i128(&self) -> Option<i128>
[src]
pub fn to_usize(&self) -> Option<usize>
[src]
pub fn to_u8(&self) -> Option<u8>
[src]
pub fn to_u16(&self) -> Option<u16>
[src]
pub fn to_u32(&self) -> Option<u32>
[src]
pub fn to_u128(&self) -> Option<u128>
[src]
pub fn to_f32(&self) -> Option<f32>
[src]
impl<T> ToSql for GenericFraction<T> where
T: Clone + GenericInteger + From<u8> + Debug,
[src]
T: Clone + GenericInteger + From<u8> + Debug,
pub fn to_sql(
&self,
ty: &Type,
buf: &mut Vec<u8>
) -> Result<IsNull, Box<dyn Error + Sync + Send>>
[src]
&self,
ty: &Type,
buf: &mut Vec<u8>
) -> Result<IsNull, Box<dyn Error + Sync + Send>>
pub fn accepts(ty: &Type) -> bool
[src]
pub fn to_sql_checked(
&self,
ty: &Type,
out: &mut Vec<u8>
) -> Result<IsNull, Box<dyn Error + Sync + Send>>
[src]
&self,
ty: &Type,
out: &mut Vec<u8>
) -> Result<IsNull, Box<dyn Error + Sync + Send>>
impl<T, F> TryToConvertFrom<GenericFraction<F>> for GenericFraction<T> where
T: TryToConvertFrom<F> + Clone + Integer,
F: Clone + Integer,
[src]
T: TryToConvertFrom<F> + Clone + Integer,
F: Clone + Integer,
pub fn try_to_convert_from(src: GenericFraction<F>) -> Option<Self>
[src]
impl<T: Clone + Integer> Zero for GenericFraction<T>
[src]
Auto Trait Implementations
impl<T> RefUnwindSafe for GenericFraction<T> where
T: RefUnwindSafe,
[src]
T: RefUnwindSafe,
impl<T> Send for GenericFraction<T> where
T: Send,
[src]
T: Send,
impl<T> Sync for GenericFraction<T> where
T: Sync,
[src]
T: Sync,
impl<T> Unpin for GenericFraction<T> where
T: Unpin,
[src]
T: Unpin,
impl<T> UnwindSafe for GenericFraction<T> where
T: UnwindSafe,
[src]
T: UnwindSafe,
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> DeserializeOwned for T where
T: for<'de> Deserialize<'de>,
[src]
T: for<'de> Deserialize<'de>,
impl<Q, K> Equivalent<K> for Q where
K: Borrow<Q> + ?Sized,
Q: Eq + ?Sized,
[src]
K: Borrow<Q> + ?Sized,
Q: Eq + ?Sized,
pub fn equivalent(&self, key: &K) -> bool
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> NumAssign for T where
T: Num + NumAssignOps<T>,
[src]
T: Num + NumAssignOps<T>,
impl<T, Rhs> NumAssignOps<Rhs> for T where
T: AddAssign<Rhs> + SubAssign<Rhs> + MulAssign<Rhs> + DivAssign<Rhs> + RemAssign<Rhs>,
[src]
T: AddAssign<Rhs> + SubAssign<Rhs> + MulAssign<Rhs> + DivAssign<Rhs> + RemAssign<Rhs>,
impl<T> NumAssignRef for T where
T: NumAssign + for<'r> NumAssignOps<&'r T>,
[src]
T: NumAssign + for<'r> NumAssignOps<&'r T>,
impl<T, Rhs, Output> NumOps<Rhs, Output> for T where
T: Sub<Rhs, Output = Output> + Mul<Rhs, Output = Output> + Div<Rhs, Output = Output> + Add<Rhs, Output = Output> + Rem<Rhs, Output = Output>,
[src]
T: Sub<Rhs, Output = Output> + Mul<Rhs, Output = Output> + Div<Rhs, Output = Output> + Add<Rhs, Output = Output> + Rem<Rhs, Output = Output>,
impl<T> Same<T> for T
type Output = T
Should always be Self
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
pub fn to_owned(&self) -> T
[src]
pub fn clone_into(&self, target: &mut T)
[src]
impl<T> ToString for T where
T: Display + ?Sized,
[src]
T: Display + ?Sized,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,