[−][src]Struct sss_rs::geometry::fraction::Fraction
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
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]
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]
fn cmp(&self, other: &Fraction) -> Ordering
[src]
fn max(self, other: Self) -> Self
1.21.0[src]
fn min(self, other: Self) -> Self
1.21.0[src]
fn clamp(self, min: Self, max: Self) -> Self
[src]
impl PartialEq<Fraction> for Fraction
[src]
impl PartialOrd<Fraction> for Fraction
[src]
fn partial_cmp(&self, other: &Fraction) -> Option<Ordering>
[src]
fn lt(&self, other: &Fraction) -> bool
[src]
fn le(&self, other: &Fraction) -> bool
[src]
fn gt(&self, other: &Fraction) -> bool
[src]
fn ge(&self, other: &Fraction) -> bool
[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.
fn div(self, rhs: Fraction) -> Self::Output
[src]
impl<'_> Div<&'_ Fraction> for Fraction
[src]
type Output = Fraction
The resulting type after applying the /
operator.
fn div(self, rhs: &Fraction) -> Self::Output
[src]
impl<'_> Div<Fraction> for &'_ Fraction
[src]
type Output = Fraction
The resulting type after applying the /
operator.
fn div(self, rhs: Fraction) -> Self::Output
[src]
impl<'_, '_> Div<&'_ Fraction> for &'_ Fraction
[src]
type Output = Fraction
The resulting type after applying the /
operator.
fn div(self, rhs: &Fraction) -> Self::Output
[src]
impl Div<i64> for Fraction
[src]
type Output = Fraction
The resulting type after applying the /
operator.
fn div(self, rhs: i64) -> Self::Output
[src]
impl<'_> Div<&'_ i64> for Fraction
[src]
type Output = Fraction
The resulting type after applying the /
operator.
fn div(self, rhs: &i64) -> Self::Output
[src]
impl<'_> Div<i64> for &'_ Fraction
[src]
type Output = Fraction
The resulting type after applying the /
operator.
fn div(self, rhs: i64) -> Self::Output
[src]
impl<'_, '_> Div<&'_ i64> for &'_ Fraction
[src]
type Output = Fraction
The resulting type after applying the /
operator.
fn div(self, rhs: &i64) -> Self::Output
[src]
impl Rem<Fraction> for Fraction
[src]
type Output = Fraction
The resulting type after applying the %
operator.
fn rem(self, rhs: Fraction) -> Self::Output
[src]
impl<'_> Rem<&'_ Fraction> for Fraction
[src]
type Output = Fraction
The resulting type after applying the %
operator.
fn rem(self, rhs: &Fraction) -> Self::Output
[src]
impl<'_> Rem<Fraction> for &'_ Fraction
[src]
type Output = Fraction
The resulting type after applying the %
operator.
fn rem(self, rhs: Fraction) -> Self::Output
[src]
impl<'_, '_> Rem<&'_ Fraction> for &'_ Fraction
[src]
type Output = Fraction
The resulting type after applying the %
operator.
fn rem(self, rhs: &Fraction) -> Self::Output
[src]
impl Rem<i64> for Fraction
[src]
type Output = Fraction
The resulting type after applying the %
operator.
fn rem(self, rhs: i64) -> Self::Output
[src]
impl<'_> Rem<&'_ i64> for Fraction
[src]
type Output = Fraction
The resulting type after applying the %
operator.
fn rem(self, rhs: &i64) -> Self::Output
[src]
impl<'_> Rem<i64> for &'_ Fraction
[src]
type Output = Fraction
The resulting type after applying the %
operator.
fn rem(self, rhs: i64) -> Self::Output
[src]
impl<'_, '_> Rem<&'_ i64> for &'_ Fraction
[src]
type Output = Fraction
The resulting type after applying the %
operator.
fn rem(self, rhs: &i64) -> Self::Output
[src]
impl Sub<Fraction> for Fraction
[src]
type Output = Fraction
The resulting type after applying the -
operator.
fn sub(self, rhs: Fraction) -> Self::Output
[src]
impl<'_> Sub<&'_ Fraction> for Fraction
[src]
type Output = Fraction
The resulting type after applying the -
operator.
fn sub(self, rhs: &Fraction) -> Self::Output
[src]
impl<'_> Sub<Fraction> for &'_ Fraction
[src]
type Output = Fraction
The resulting type after applying the -
operator.
fn sub(self, rhs: Fraction) -> Self::Output
[src]
impl<'_, '_> Sub<&'_ Fraction> for &'_ Fraction
[src]
type Output = Fraction
The resulting type after applying the -
operator.
fn sub(self, rhs: &Fraction) -> Self::Output
[src]
impl Sub<i64> for Fraction
[src]
type Output = Fraction
The resulting type after applying the -
operator.
fn sub(self, rhs: i64) -> Self::Output
[src]
impl<'_> Sub<&'_ i64> for Fraction
[src]
type Output = Fraction
The resulting type after applying the -
operator.
fn sub(self, rhs: &i64) -> Self::Output
[src]
impl<'_> Sub<i64> for &'_ Fraction
[src]
type Output = Fraction
The resulting type after applying the -
operator.
fn sub(self, rhs: i64) -> Self::Output
[src]
impl<'_, '_> Sub<&'_ i64> for &'_ Fraction
[src]
type Output = Fraction
The resulting type after applying the -
operator.
fn sub(self, rhs: &i64) -> Self::Output
[src]
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.
fn try_from(fraction: Fraction) -> Result<Self, Self::Error>
[src]
impl Add<Fraction> for Fraction
[src]
type Output = Fraction
The resulting type after applying the +
operator.
fn add(self, rhs: Fraction) -> Self::Output
[src]
impl<'_> Add<&'_ Fraction> for Fraction
[src]
type Output = Fraction
The resulting type after applying the +
operator.
fn add(self, rhs: &Fraction) -> Self::Output
[src]
impl<'_> Add<Fraction> for &'_ Fraction
[src]
type Output = Fraction
The resulting type after applying the +
operator.
fn add(self, rhs: Fraction) -> Self::Output
[src]
impl<'_, '_> Add<&'_ Fraction> for &'_ Fraction
[src]
type Output = Fraction
The resulting type after applying the +
operator.
fn add(self, rhs: &Fraction) -> Self::Output
[src]
impl Add<i64> for Fraction
[src]
type Output = Fraction
The resulting type after applying the +
operator.
fn add(self, rhs: i64) -> Self::Output
[src]
impl<'_> Add<&'_ i64> for Fraction
[src]
type Output = Fraction
The resulting type after applying the +
operator.
fn add(self, rhs: &i64) -> Self::Output
[src]
impl<'_> Add<i64> for &'_ Fraction
[src]
type Output = Fraction
The resulting type after applying the +
operator.
fn add(self, rhs: i64) -> Self::Output
[src]
impl<'_, '_> Add<&'_ i64> for &'_ Fraction
[src]
type Output = Fraction
The resulting type after applying the +
operator.
fn add(self, rhs: &i64) -> Self::Output
[src]
impl Mul<Fraction> for Fraction
[src]
type Output = Fraction
The resulting type after applying the *
operator.
fn mul(self, rhs: Fraction) -> Self::Output
[src]
impl<'_> Mul<&'_ Fraction> for Fraction
[src]
type Output = Fraction
The resulting type after applying the *
operator.
fn mul(self, rhs: &Fraction) -> Self::Output
[src]
impl<'_> Mul<Fraction> for &'_ Fraction
[src]
type Output = Fraction
The resulting type after applying the *
operator.
fn mul(self, rhs: Fraction) -> Self::Output
[src]
impl<'_, '_> Mul<&'_ Fraction> for &'_ Fraction
[src]
type Output = Fraction
The resulting type after applying the *
operator.
fn mul(self, rhs: &Fraction) -> Self::Output
[src]
impl Mul<i64> for Fraction
[src]
type Output = Fraction
The resulting type after applying the *
operator.
fn mul(self, rhs: i64) -> Self::Output
[src]
impl<'_> Mul<&'_ i64> for Fraction
[src]
type Output = Fraction
The resulting type after applying the *
operator.
fn mul(self, rhs: &i64) -> Self::Output
[src]
impl<'_> Mul<i64> for &'_ Fraction
[src]
type Output = Fraction
The resulting type after applying the *
operator.
fn mul(self, rhs: i64) -> Self::Output
[src]
impl<'_, '_> Mul<&'_ i64> for &'_ Fraction
[src]
type Output = Fraction
The resulting type after applying the *
operator.
fn mul(self, rhs: &i64) -> Self::Output
[src]
impl Mul<Fraction> for Term
[src]
type Output = Term
The resulting type after applying the *
operator.
fn mul(self, rhs: Fraction) -> Self::Output
[src]
impl<'_> Mul<&'_ Fraction> for Term
[src]
type Output = Term
The resulting type after applying the *
operator.
fn mul(self, rhs: &Fraction) -> Self::Output
[src]
impl<'_> Mul<Fraction> for &'_ Term
[src]
type Output = Term
The resulting type after applying the *
operator.
fn mul(self, rhs: Fraction) -> Self::Output
[src]
impl<'_, '_> Mul<&'_ Fraction> for &'_ Term
[src]
type Output = Term
The resulting type after applying the *
operator.
fn mul(self, rhs: &Fraction) -> Self::Output
[src]
impl Neg for Fraction
[src]
type Output = Fraction
The resulting type after applying the -
operator.
fn neg(self) -> Self::Output
[src]
impl<'_> Neg for &'_ Fraction
[src]
type Output = Fraction
The resulting type after applying the -
operator.
fn neg(self) -> Self::Output
[src]
impl Pow<i32> for Fraction
[src]
type Output = Fraction
The result after applying the operator.
fn pow(self, rhs: i32) -> Fraction
[src]
impl Pow<u32> for Fraction
[src]
Auto Trait Implementations
impl Send for Fraction
impl Sync for Fraction
impl Unpin for Fraction
impl UnwindSafe for Fraction
impl RefUnwindSafe for Fraction
Blanket Implementations
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> From<T> for T
[src]
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
fn to_owned(&self) -> T
[src]
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 = !
The type returned in the event of a conversion error.
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>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
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, Base> RefNum<Base> for T where
T: NumOps<Base, Base> + NumOps<&'r Base, Base>,
[src]
T: NumOps<Base, Base> + NumOps<&'r Base, Base>,