[][src]Struct sss_rs::geometry::fraction::Fraction

pub struct Fraction { /* fields omitted */ }

A signed numerical value that is used to represent a fractional value or a whole value without having to worry about decimals and truncating. While both the @numerator and @denominator are signed values, only the numerator is allowed to be negative. The denominator is signed to make mathematical operations easier and will sometimes need to be negative during an operation but the sign will be moved to the numerator automatically

Methods

impl Fraction[src]

pub fn new(numerator: i64, denominator: i64) -> Self[src]

Creates a new fraction with the given numerator and denominator, which accepts any value that implements Into. @numerator: The numerator of the fraction @denominator: The denominator of the fraction

pub fn get_numerator(&self) -> i64[src]

Returns a reference to the numerator of the fraction

pub fn get_denominator(&self) -> i64[src]

Returns a reference to the denominator of the fraction

pub fn negate(self) -> Self[src]

Consumes the fraction and returns the negation of it

pub fn add_fraction(self, other: Fraction) -> Self[src]

Consuming add operation

pub fn sub_fraction(self, other: Fraction) -> Self[src]

Consuming sub operation

pub fn mul_fraction(self, other: Fraction) -> Self[src]

Consuming multiplication operation

pub fn div_fraction(self, other: Fraction) -> Self[src]

Consuming division operation

pub fn mod_fraction(self, rhs: Fraction) -> Self[src]

Consuming modulo operation

pub fn add_i64(self, rhs: i64) -> Self[src]

Consuming add operation with the right hand side being a i64

pub fn sub_i64(self, rhs: i64) -> Self[src]

Consuming sub operation with the right hand side being a i64

pub fn mul_i64(self, rhs: i64) -> Self[src]

Consuming multiplication operation with the right hand side being a i64

pub fn div_i64(self, rhs: i64) -> Self[src]

Consuming division operation with the right hand side being a i64

pub fn mod_i64(self, rhs: i64) -> Self[src]

Consuming modulo operation with the right hand side being a i64

pub fn floor(self) -> Self[src]

Consuming floor operation that "truncates" the fraction to a whole number

pub fn ceiling(self) -> Self[src]

pub fn abs(self) -> Self[src]

Consuming absolute value operation, if the fraction is negative, it is made positive

pub fn match_denominator(&mut self, other: &mut Fraction)[src]

Matches the denominator of @self and another given fraction, which is used to make addtion and subtraction operations possible.

pub fn flip(self) -> Self[src]

Consuming operation that flips the fraction

pub fn is_whole(&self) -> bool[src]

Checks if the given fraction is a whole number, returns true if it is, false otherwise

Trait Implementations

impl NaturalMod<i64> for Fraction[src]

type Output_ = Fraction

impl AsRef<Fraction> for Term[src]

impl<T: Into<i64> + Debug> From<T> for Fraction[src]

impl Clone for Fraction[src]

impl Copy for Fraction[src]

impl Default for Fraction[src]

impl Eq for Fraction[src]

impl Ord for Fraction[src]

impl PartialEq<Fraction> for Fraction[src]

impl PartialOrd<Fraction> for Fraction[src]

impl Display for Fraction[src]

impl Debug for Fraction[src]

impl Div<Fraction> for Fraction[src]

type Output = Fraction

The resulting type after applying the / operator.

impl<'_> Div<&'_ Fraction> for Fraction[src]

type Output = Fraction

The resulting type after applying the / operator.

impl<'_> Div<Fraction> for &'_ Fraction[src]

type Output = Fraction

The resulting type after applying the / operator.

impl<'_, '_> Div<&'_ Fraction> for &'_ Fraction[src]

type Output = Fraction

The resulting type after applying the / operator.

impl Div<i64> for Fraction[src]

type Output = Fraction

The resulting type after applying the / operator.

impl<'_> Div<&'_ i64> for Fraction[src]

type Output = Fraction

The resulting type after applying the / operator.

impl<'_> Div<i64> for &'_ Fraction[src]

type Output = Fraction

The resulting type after applying the / operator.

impl<'_, '_> Div<&'_ i64> for &'_ Fraction[src]

type Output = Fraction

The resulting type after applying the / operator.

impl Rem<Fraction> for Fraction[src]

type Output = Fraction

The resulting type after applying the % operator.

impl<'_> Rem<&'_ Fraction> for Fraction[src]

type Output = Fraction

The resulting type after applying the % operator.

impl<'_> Rem<Fraction> for &'_ Fraction[src]

type Output = Fraction

The resulting type after applying the % operator.

impl<'_, '_> Rem<&'_ Fraction> for &'_ Fraction[src]

type Output = Fraction

The resulting type after applying the % operator.

impl Rem<i64> for Fraction[src]

type Output = Fraction

The resulting type after applying the % operator.

impl<'_> Rem<&'_ i64> for Fraction[src]

type Output = Fraction

The resulting type after applying the % operator.

impl<'_> Rem<i64> for &'_ Fraction[src]

type Output = Fraction

The resulting type after applying the % operator.

impl<'_, '_> Rem<&'_ i64> for &'_ Fraction[src]

type Output = Fraction

The resulting type after applying the % operator.

impl Sub<Fraction> for Fraction[src]

type Output = Fraction

The resulting type after applying the - operator.

impl<'_> Sub<&'_ Fraction> for Fraction[src]

type Output = Fraction

The resulting type after applying the - operator.

impl<'_> Sub<Fraction> for &'_ Fraction[src]

type Output = Fraction

The resulting type after applying the - operator.

impl<'_, '_> Sub<&'_ Fraction> for &'_ Fraction[src]

type Output = Fraction

The resulting type after applying the - operator.

impl Sub<i64> for Fraction[src]

type Output = Fraction

The resulting type after applying the - operator.

impl<'_> Sub<&'_ i64> for Fraction[src]

type Output = Fraction

The resulting type after applying the - operator.

impl<'_> Sub<i64> for &'_ Fraction[src]

type Output = Fraction

The resulting type after applying the - operator.

impl<'_, '_> Sub<&'_ i64> for &'_ Fraction[src]

type Output = Fraction

The resulting type after applying the - operator.

impl TryFrom<Fraction> for i64[src]

Attempts to convert a Fraction into a i64. Will return an error if the fraction is not a whole number. If truncation is the goal, first call floor and then either TryFrom or @get_numerator

type Error = String

The type returned in the event of a conversion error.

impl Add<Fraction> for Fraction[src]

type Output = Fraction

The resulting type after applying the + operator.

impl<'_> Add<&'_ Fraction> for Fraction[src]

type Output = Fraction

The resulting type after applying the + operator.

impl<'_> Add<Fraction> for &'_ Fraction[src]

type Output = Fraction

The resulting type after applying the + operator.

impl<'_, '_> Add<&'_ Fraction> for &'_ Fraction[src]

type Output = Fraction

The resulting type after applying the + operator.

impl Add<i64> for Fraction[src]

type Output = Fraction

The resulting type after applying the + operator.

impl<'_> Add<&'_ i64> for Fraction[src]

type Output = Fraction

The resulting type after applying the + operator.

impl<'_> Add<i64> for &'_ Fraction[src]

type Output = Fraction

The resulting type after applying the + operator.

impl<'_, '_> Add<&'_ i64> for &'_ Fraction[src]

type Output = Fraction

The resulting type after applying the + operator.

impl Mul<Fraction> for Fraction[src]

type Output = Fraction

The resulting type after applying the * operator.

impl<'_> Mul<&'_ Fraction> for Fraction[src]

type Output = Fraction

The resulting type after applying the * operator.

impl<'_> Mul<Fraction> for &'_ Fraction[src]

type Output = Fraction

The resulting type after applying the * operator.

impl<'_, '_> Mul<&'_ Fraction> for &'_ Fraction[src]

type Output = Fraction

The resulting type after applying the * operator.

impl Mul<i64> for Fraction[src]

type Output = Fraction

The resulting type after applying the * operator.

impl<'_> Mul<&'_ i64> for Fraction[src]

type Output = Fraction

The resulting type after applying the * operator.

impl<'_> Mul<i64> for &'_ Fraction[src]

type Output = Fraction

The resulting type after applying the * operator.

impl<'_, '_> Mul<&'_ i64> for &'_ Fraction[src]

type Output = Fraction

The resulting type after applying the * operator.

impl Mul<Fraction> for Term[src]

type Output = Term

The resulting type after applying the * operator.

impl<'_> Mul<&'_ Fraction> for Term[src]

type Output = Term

The resulting type after applying the * operator.

impl<'_> Mul<Fraction> for &'_ Term[src]

type Output = Term

The resulting type after applying the * operator.

impl<'_, '_> Mul<&'_ Fraction> for &'_ Term[src]

type Output = Term

The resulting type after applying the * operator.

impl Neg for Fraction[src]

type Output = Fraction

The resulting type after applying the - operator.

impl<'_> Neg for &'_ Fraction[src]

type Output = Fraction

The resulting type after applying the - operator.

impl Pow<i32> for Fraction[src]

type Output = Fraction

The result after applying the operator.

impl Pow<u32> for Fraction[src]

type Output = Fraction

The result after applying the operator.

Auto Trait Implementations

Blanket Implementations

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

impl<T> From<T> for T[src]

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

type Owned = T

The resulting type after obtaining ownership.

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

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

type Error = !

The type returned in the event of a conversion error.

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

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

The type returned in the event of a conversion error.

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

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

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

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]

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