pub struct Rational(pub(crate) Rational);
Tuple Fields§
§0: Rational
Implementations§
source§impl Rational
impl Rational
pub const MINUS_TWO: Self = _
pub const MINUS_ONE: Self = _
pub const ZERO: Self = _
pub const ONE: Self = _
pub const TWO: Self = _
pub const fn new_int(n: i64) -> Self
pub fn numer(&self) -> Int
pub fn to_int(&self) -> Option<Int>
pub fn denom(&self) -> Int
pub fn is_zero(&self) -> bool
pub fn is_one(&self) -> bool
pub fn is_pos(&self) -> bool
pub fn is_neg(&self) -> bool
pub fn is_int(&self) -> bool
pub fn abs(self) -> Self
pub fn div_rem(&self) -> (Self, Self)
sourcepub fn pow(self, rhs: Self) -> (Self, Self)
pub fn pow(self, rhs: Self) -> (Self, Self)
will calculate self to the power of an integer number.
if the exponent is (a/b) non-int: we calculate the power to the int quotient of a/b and return the remainder: (self^quot, rem).
n^(a/b) = n^(quot + rem) = n^(quot) * n^(rem) -> (n^quot, rem)
quot: Int, rest: Fraction, n^(quot): Rational
returns the input if calculation was not possible
pub fn pow_basic(self, rhs: Self) -> Option<Self>
Trait Implementations§
source§impl AddAssign<&Rational> for Rational
impl AddAssign<&Rational> for Rational
source§fn add_assign(&mut self, rhs: &Self)
fn add_assign(&mut self, rhs: &Self)
Performs the
+=
operation. Read moresource§impl AddAssign for Rational
impl AddAssign for Rational
source§fn add_assign(&mut self, rhs: Self)
fn add_assign(&mut self, rhs: Self)
Performs the
+=
operation. Read moresource§impl MulAssign<&Rational> for Rational
impl MulAssign<&Rational> for Rational
source§fn mul_assign(&mut self, rhs: &Self)
fn mul_assign(&mut self, rhs: &Self)
Performs the
*=
operation. Read moresource§impl MulAssign for Rational
impl MulAssign for Rational
source§fn mul_assign(&mut self, rhs: Self)
fn mul_assign(&mut self, rhs: Self)
Performs the
*=
operation. Read moresource§impl Ord for Rational
impl Ord for Rational
source§impl PartialEq for Rational
impl PartialEq for Rational
source§impl PartialOrd for Rational
impl PartialOrd for Rational
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
This method tests less than or equal to (for
self
and other
) and is used by the <=
operator. Read moresource§impl SubAssign<&Rational> for Rational
impl SubAssign<&Rational> for Rational
source§fn sub_assign(&mut self, rhs: &Self)
fn sub_assign(&mut self, rhs: &Self)
Performs the
-=
operation. Read moresource§impl SubAssign for Rational
impl SubAssign for Rational
source§fn sub_assign(&mut self, rhs: Self)
fn sub_assign(&mut self, rhs: Self)
Performs the
-=
operation. Read moreimpl Eq for Rational
impl StructuralPartialEq for Rational
Auto Trait Implementations§
impl Freeze for Rational
impl RefUnwindSafe for Rational
impl Send for Rational
impl Sync for Rational
impl Unpin for Rational
impl UnwindSafe for Rational
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
Mutably borrows from an owned value. Read more
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§default unsafe fn clone_to_uninit(&self, dst: *mut T)
default unsafe fn clone_to_uninit(&self, dst: *mut T)
🔬This is a nightly-only experimental API. (
clone_to_uninit
)§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Checks if this value is equivalent to the given key. Read more
§impl<T, U> ExactFrom<T> for Uwhere
U: TryFrom<T>,
impl<T, U> ExactFrom<T> for Uwhere
U: TryFrom<T>,
fn exact_from(value: T) -> U
§impl<T, U> ExactInto<U> for Twhere
U: ExactFrom<T>,
impl<T, U> ExactInto<U> for Twhere
U: ExactFrom<T>,
fn exact_into(self) -> U
source§impl<T> IntoEither for T
impl<T> IntoEither for T
source§fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moresource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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