pub enum Factor {
NegativeOne,
Zero,
One,
Prime(u128, i8),
OneOverZero,
ZeroOverZero,
}
Expand description
A prime factor of a fraction.
Variants§
NegativeOne
The negative multiplicative base, -1. Only a factor of negative fractions.
Zero
The additive base, 0. Only a factor if the fraction evaluates to 0.
One
The multiplicative base, 1. Only a factor if the fraction evaluates to 1.
Prime(u128, i8)
A prime number with an exponent. Appears in most fractions.
OneOverZero
Positive infinity, 1/0. Only a factor if the fraction involves a division by zero.
ZeroOverZero
An undefined value, 0/0. Only a factor if the fraction evaluates to 0/0.
Implementations§
Source§impl Factor
impl Factor
Sourcepub const fn has_exponent(&self) -> bool
pub const fn has_exponent(&self) -> bool
Determines if this factor would be displayed with an exponent or not. For primes, returns false if the exponent is 1 and true otherwise. Always returns false for other variants.
§Examples
Basic usage:
assert!(!Factor::NegativeOne.has_exponent());
assert!(Factor::Prime(2, 2).has_exponent());
assert!(!Factor::OneOverZero.has_exponent());
Trait Implementations§
Source§impl Ord for Factor
impl Ord for Factor
Source§impl PartialOrd for Factor
impl PartialOrd for Factor
impl Copy for Factor
impl Eq for Factor
impl StructuralPartialEq for Factor
Auto Trait Implementations§
impl Freeze for Factor
impl RefUnwindSafe for Factor
impl Send for Factor
impl Sync for Factor
impl Unpin for Factor
impl UnwindSafe for Factor
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§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