Ratio

Struct Ratio 

Source
pub struct Ratio<T> { /* private fields */ }

Implementations§

Source§

impl<T> Ratio<T>

Source

pub const fn numer(&self) -> &T

Source

pub const fn denom(&self) -> &T

Source§

impl<T> Ratio<T>
where T: EucRing, for<'x> &'x T: EucRingOps<T>,

Source

pub fn new(numer: T, denom: T) -> Ratio<T>

Source

pub fn is_int(&self) -> bool

Source§

impl<T> Ratio<T>
where T: Integer, for<'x> &'x T: IntOps<T>,

Source

pub fn abs(&self) -> Self

Source

pub fn to_f64(&self) -> f64

Trait Implementations§

Source§

impl<T> Add<&Ratio<T>> for &Ratio<T>
where T: EucRing, for<'x> &'x T: EucRingOps<T>, Ratio<T>: Clone,

Source§

type Output = Ratio<T>

The resulting type after applying the + operator.
Source§

fn add(self, rhs: &Ratio<T>) -> Self::Output

Performs the + operation. Read more
Source§

impl<T> Add<&Ratio<T>> for Ratio<T>
where T: EucRing, for<'x> &'x T: EucRingOps<T>,

Source§

type Output = Ratio<T>

The resulting type after applying the + operator.
Source§

fn add(self, rhs: &Ratio<T>) -> Self::Output

Performs the + operation. Read more
Source§

impl<T> Add<Ratio<T>> for &Ratio<T>
where T: EucRing, for<'x> &'x T: EucRingOps<T>, Ratio<T>: Clone,

Source§

type Output = Ratio<T>

The resulting type after applying the + operator.
Source§

fn add(self, rhs: Ratio<T>) -> Self::Output

Performs the + operation. Read more
Source§

impl<T> Add for Ratio<T>
where T: EucRing, for<'x> &'x T: EucRingOps<T>,

Source§

type Output = Ratio<T>

The resulting type after applying the + operator.
Source§

fn add(self, rhs: Ratio<T>) -> Self::Output

Performs the + operation. Read more
Source§

impl<T> AddAssign<&Ratio<T>> for Ratio<T>
where T: EucRing, for<'x> &'x T: EucRingOps<T>,

Source§

fn add_assign(&mut self, rhs: &Ratio<T>)

Performs the += operation. Read more
Source§

impl<T> AddAssign for Ratio<T>
where T: EucRing, for<'x> &'x T: EucRingOps<T>,

Source§

fn add_assign(&mut self, rhs: Ratio<T>)

Performs the += operation. Read more
Source§

impl<T> AddMon for Ratio<T>
where T: EucRing, for<'x> &'x T: EucRingOps<T>,

Source§

fn sum<A, I>(itr: I) -> Self
where Self: AddAssign<A>, I: IntoIterator<Item = A>,

Source§

impl<T: Clone> Clone for Ratio<T>

Source§

fn clone(&self) -> Ratio<T>

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<T> Debug for Ratio<T>
where T: Display,

Source§

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

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

impl<T> Default for Ratio<T>
where T: Default + One,

Source§

fn default() -> Self

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

impl<T> Display for Ratio<T>
where T: Display,

Source§

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

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

impl<T> Div<&Ratio<T>> for &Ratio<T>
where T: EucRing, for<'x> &'x T: EucRingOps<T>, Ratio<T>: Clone,

Source§

type Output = Ratio<T>

The resulting type after applying the / operator.
Source§

fn div(self, rhs: &Ratio<T>) -> Self::Output

Performs the / operation. Read more
Source§

impl<T> Div<&Ratio<T>> for Ratio<T>
where T: EucRing, for<'x> &'x T: EucRingOps<T>,

Source§

type Output = Ratio<T>

The resulting type after applying the / operator.
Source§

fn div(self, rhs: &Ratio<T>) -> Self::Output

Performs the / operation. Read more
Source§

impl<T> Div<Ratio<T>> for &Ratio<T>
where T: EucRing, for<'x> &'x T: EucRingOps<T>, Ratio<T>: Clone,

Source§

type Output = Ratio<T>

The resulting type after applying the / operator.
Source§

fn div(self, rhs: Ratio<T>) -> Self::Output

Performs the / operation. Read more
Source§

impl<T> Div for Ratio<T>
where T: EucRing, for<'x> &'x T: EucRingOps<T>,

Source§

type Output = Ratio<T>

The resulting type after applying the / operator.
Source§

fn div(self, rhs: Ratio<T>) -> Self::Output

Performs the / operation. Read more
Source§

impl<T> DivAssign<&Ratio<T>> for Ratio<T>
where T: EucRing, for<'x> &'x T: EucRingOps<T>,

Source§

fn div_assign(&mut self, rhs: &Ratio<T>)

Performs the /= operation. Read more
Source§

impl<T> DivAssign for Ratio<T>
where T: EucRing, for<'x> &'x T: EucRingOps<T>,

Source§

fn div_assign(&mut self, rhs: Ratio<T>)

Performs the /= operation. Read more
Source§

impl<T> Elem for Ratio<T>
where T: EucRing, for<'x> &'x T: EucRingOps<T>,

Source§

impl<T> EucRing for Ratio<T>
where T: EucRing, for<'x> &'x T: EucRingOps<T>,

Source§

fn divides(&self, y: &Self) -> bool

Source§

fn gcd(x: &Self, y: &Self) -> Self

Source§

fn gcdx(x: &Self, y: &Self) -> (Self, Self, Self)

Source§

fn lcm(x: &Self, y: &Self) -> Self

Source§

impl<T> From<(T, T)> for Ratio<T>
where T: EucRing, for<'x> &'x T: EucRingOps<T>,

Source§

fn from(pair: (T, T)) -> Self

Converts to this type from the input type.
Source§

impl<T> From<T> for Ratio<T>
where T: One,

Source§

fn from(a: T) -> Self

Converts to this type from the input type.
Source§

impl<T> FromStr for Ratio<T>
where T: EucRing + FromStr, for<'x> &'x T: EucRingOps<T>,

Source§

type Err = String

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

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

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

impl<T> Mon for Ratio<T>
where T: EucRing, for<'x> &'x T: EucRingOps<T>,

Source§

fn product<A, I>(itr: I) -> Self
where Self: MulAssign<A>, I: IntoIterator<Item = A>,

Source§

impl<T> Mul<&Ratio<T>> for &Ratio<T>
where T: EucRing, for<'x> &'x T: EucRingOps<T>, Ratio<T>: Clone,

Source§

type Output = Ratio<T>

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: &Ratio<T>) -> Self::Output

Performs the * operation. Read more
Source§

impl<T> Mul<&Ratio<T>> for Ratio<T>
where T: EucRing, for<'x> &'x T: EucRingOps<T>,

Source§

type Output = Ratio<T>

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: &Ratio<T>) -> Self::Output

Performs the * operation. Read more
Source§

impl<T> Mul<Ratio<T>> for &Ratio<T>
where T: EucRing, for<'x> &'x T: EucRingOps<T>, Ratio<T>: Clone,

Source§

type Output = Ratio<T>

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: Ratio<T>) -> Self::Output

Performs the * operation. Read more
Source§

impl<T> Mul for Ratio<T>
where T: EucRing, for<'x> &'x T: EucRingOps<T>,

Source§

type Output = Ratio<T>

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: Ratio<T>) -> Self::Output

Performs the * operation. Read more
Source§

impl<T> MulAssign<&Ratio<T>> for Ratio<T>
where T: EucRing, for<'x> &'x T: EucRingOps<T>,

Source§

fn mul_assign(&mut self, rhs: &Ratio<T>)

Performs the *= operation. Read more
Source§

impl<T> MulAssign for Ratio<T>
where T: EucRing, for<'x> &'x T: EucRingOps<T>,

Source§

fn mul_assign(&mut self, rhs: Ratio<T>)

Performs the *= operation. Read more
Source§

impl<T> Neg for &Ratio<T>
where T: EucRing, for<'x> &'x T: EucRingOps<T>,

Source§

type Output = Ratio<T>

The resulting type after applying the - operator.
Source§

fn neg(self) -> Self::Output

Performs the unary - operation. Read more
Source§

impl<T> Neg for Ratio<T>
where T: EucRing, for<'x> &'x T: EucRingOps<T>,

Source§

type Output = Ratio<T>

The resulting type after applying the - operator.
Source§

fn neg(self) -> Self::Output

Performs the unary - operation. Read more
Source§

impl<T> One for Ratio<T>
where T: EucRing, for<'x> &'x T: EucRingOps<T>,

Source§

fn one() -> Self

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

fn is_one(&self) -> bool

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

fn set_one(&mut self)

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

impl<T> Ord for Ratio<T>
where T: Integer, for<'x> &'x T: IntOps<T>,

Source§

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

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

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

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

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

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

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

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

impl<T: PartialEq> PartialEq for Ratio<T>

Source§

fn eq(&self, other: &Ratio<T>) -> bool

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

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

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

impl<T> PartialOrd for Ratio<T>
where T: Integer, for<'x> &'x T: IntOps<T>,

Source§

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

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

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

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

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

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

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

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

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

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

impl<'a, 'b, T> Rem<&'b Ratio<T>> for &'a Ratio<T>
where T: EucRing, for<'x> &'x T: EucRingOps<T>,

Source§

type Output = Ratio<T>

The resulting type after applying the % operator.
Source§

fn rem(self, rhs: &'b Ratio<T>) -> Self::Output

Performs the % operation. Read more
Source§

impl<'a, 'b, T> Rem<&'b Ratio<T>> for Ratio<T>
where T: EucRing, for<'x> &'x T: EucRingOps<T>,

Source§

type Output = Ratio<T>

The resulting type after applying the % operator.
Source§

fn rem(self, rhs: &'b Ratio<T>) -> Self::Output

Performs the % operation. Read more
Source§

impl<'a, 'b, T> Rem<Ratio<T>> for &'a Ratio<T>
where T: EucRing, for<'x> &'x T: EucRingOps<T>,

Source§

type Output = Ratio<T>

The resulting type after applying the % operator.
Source§

fn rem(self, rhs: Ratio<T>) -> Self::Output

Performs the % operation. Read more
Source§

impl<'a, 'b, T> Rem for Ratio<T>
where T: EucRing, for<'x> &'x T: EucRingOps<T>,

Source§

type Output = Ratio<T>

The resulting type after applying the % operator.
Source§

fn rem(self, rhs: Ratio<T>) -> Self::Output

Performs the % operation. Read more
Source§

impl<'a, 'b, T> RemAssign<&'b Ratio<T>> for Ratio<T>
where T: EucRing, for<'x> &'x T: EucRingOps<T>,

Source§

fn rem_assign(&mut self, rhs: &'b Ratio<T>)

Performs the %= operation. Read more
Source§

impl<'a, 'b, T> RemAssign for Ratio<T>
where T: EucRing, for<'x> &'x T: EucRingOps<T>,

Source§

fn rem_assign(&mut self, rhs: Ratio<T>)

Performs the %= operation. Read more
Source§

impl<T> Ring for Ratio<T>
where T: EucRing, for<'x> &'x T: EucRingOps<T>,

Source§

fn inv(&self) -> Option<Self>

Source§

fn is_unit(&self) -> bool

Source§

fn normalizing_unit(&self) -> Self

Source§

fn c_weight(&self) -> f64

Source§

fn from_sign(s: Sign) -> Self

Source§

fn normalized(&self) -> Self

Source§

fn into_normalized(self) -> Self

Source§

fn is_pm_one(&self) -> bool

Source§

impl<T> Sub<&Ratio<T>> for &Ratio<T>
where T: EucRing, for<'x> &'x T: EucRingOps<T>, Ratio<T>: Clone,

Source§

type Output = Ratio<T>

The resulting type after applying the - operator.
Source§

fn sub(self, rhs: &Ratio<T>) -> Self::Output

Performs the - operation. Read more
Source§

impl<T> Sub<&Ratio<T>> for Ratio<T>
where T: EucRing, for<'x> &'x T: EucRingOps<T>,

Source§

type Output = Ratio<T>

The resulting type after applying the - operator.
Source§

fn sub(self, rhs: &Ratio<T>) -> Self::Output

Performs the - operation. Read more
Source§

impl<T> Sub<Ratio<T>> for &Ratio<T>
where T: EucRing, for<'x> &'x T: EucRingOps<T>, Ratio<T>: Clone,

Source§

type Output = Ratio<T>

The resulting type after applying the - operator.
Source§

fn sub(self, rhs: Ratio<T>) -> Self::Output

Performs the - operation. Read more
Source§

impl<T> Sub for Ratio<T>
where T: EucRing, for<'x> &'x T: EucRingOps<T>,

Source§

type Output = Ratio<T>

The resulting type after applying the - operator.
Source§

fn sub(self, rhs: Ratio<T>) -> Self::Output

Performs the - operation. Read more
Source§

impl<T> SubAssign<&Ratio<T>> for Ratio<T>
where T: EucRing, for<'x> &'x T: EucRingOps<T>,

Source§

fn sub_assign(&mut self, rhs: &Ratio<T>)

Performs the -= operation. Read more
Source§

impl<T> SubAssign for Ratio<T>
where T: EucRing, for<'x> &'x T: EucRingOps<T>,

Source§

fn sub_assign(&mut self, rhs: Ratio<T>)

Performs the -= operation. Read more
Source§

impl<T> Zero for Ratio<T>
where T: EucRing, for<'x> &'x T: EucRingOps<T>,

Source§

fn zero() -> Self

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

fn is_zero(&self) -> bool

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

fn set_zero(&mut self)

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

impl<T> AddGrp for Ratio<T>
where T: EucRing, for<'x> &'x T: EucRingOps<T>,

Source§

impl<T> AddGrpOps<Ratio<T>> for &Ratio<T>
where T: EucRing, for<'x> &'x T: EucRingOps<T>,

Source§

impl<T> AddGrpOps for Ratio<T>
where T: EucRing, for<'x> &'x T: EucRingOps<T>,

Source§

impl<T> AddMonOps<Ratio<T>> for &Ratio<T>
where T: EucRing, for<'x> &'x T: EucRingOps<T>,

Source§

impl<T> AddMonOps for Ratio<T>
where T: EucRing, for<'x> &'x T: EucRingOps<T>,

Source§

impl<T: Copy> Copy for Ratio<T>

Source§

impl<T: Eq> Eq for Ratio<T>

Source§

impl<T> EucRingOps<Ratio<T>> for &Ratio<T>
where T: EucRing, for<'x> &'x T: EucRingOps<T>,

Source§

impl<T> EucRingOps for Ratio<T>
where T: EucRing, for<'x> &'x T: EucRingOps<T>,

Source§

impl<T> Field for Ratio<T>
where T: EucRing, for<'x> &'x T: EucRingOps<T>,

Source§

impl<T> FieldOps<Ratio<T>> for &Ratio<T>
where T: EucRing, for<'x> &'x T: EucRingOps<T>,

Source§

impl<T> FieldOps for Ratio<T>
where T: EucRing, for<'x> &'x T: EucRingOps<T>,

Source§

impl<T> MonOps<Ratio<T>> for &Ratio<T>
where T: EucRing, for<'x> &'x T: EucRingOps<T>,

Source§

impl<T> MonOps for Ratio<T>
where T: EucRing, for<'x> &'x T: EucRingOps<T>,

Source§

impl<T> RingOps<Ratio<T>> for &Ratio<T>
where T: EucRing, for<'x> &'x T: EucRingOps<T>,

Source§

impl<T> RingOps for Ratio<T>
where T: EucRing, for<'x> &'x T: EucRingOps<T>,

Source§

impl<T> StructuralPartialEq for Ratio<T>

Auto Trait Implementations§

§

impl<T> Freeze for Ratio<T>
where T: Freeze,

§

impl<T> RefUnwindSafe for Ratio<T>
where T: RefUnwindSafe,

§

impl<T> Send for Ratio<T>
where T: Send,

§

impl<T> Sync for Ratio<T>
where T: Sync,

§

impl<T> Unpin for Ratio<T>
where T: Unpin,

§

impl<T> UnwindSafe for Ratio<T>
where T: UnwindSafe,

Blanket Implementations§

Source§

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

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

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

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

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

Source§

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

Mutably borrows from an owned value. Read more
Source§

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

Source§

fn clone_and<F>(&self, f: F) -> Self
where F: FnOnce(&mut Self),

Source§

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

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

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

Source§

fn into(self) -> U

Calls U::from(self).

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

Source§

impl<T> IntoEither for T

Source§

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

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

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

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

impl<T, Rhs> PowMod2<Rhs> for T
where T: One, Rhs: IsEven,

Source§

fn pow_mod2(self, rhs: Rhs) -> Self

Source§

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

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

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

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

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

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

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

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

Source§

type Error = Infallible

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

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

Performs the conversion.
Source§

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

Source§

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

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

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

Performs the conversion.
Source§

impl<T> ElemBase for T
where T: Default + PartialEq + Eq + Clone + Send + Sync + Display + Debug + 'static,

Source§

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

Source§

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

Source§

impl<T, Base> RefNum<Base> for T
where T: NumOps<Base, Base> + for<'r> NumOps<&'r Base, Base>,