pub struct Fraction(pub Rational32);
Tuple Fields§
§0: Rational32
Implementations§
source§impl Fraction
impl Fraction
sourcepub const fn new_raw(numer: i32, denom: i32) -> Self
pub const fn new_raw(numer: i32, denom: i32) -> Self
Creates a Fraction
without checking for denom == 0
or reducing.
While this does not panic, there are several methods that will panic
if used on a Fraction
with denom == 0
.
sourcepub const fn from_integer(t: i32) -> Self
pub const fn from_integer(t: i32) -> Self
Creates a Fraction
representing the integer t
.
pub fn approximate_f32(x: f32) -> Option<Self>
pub fn approximate_f64(x: f64) -> Option<Self>
pub fn numer(&self) -> i32
pub fn denom(&self) -> i32
pub fn simplify(&mut self, n_terms: u32, threshold: u32)
Trait Implementations§
source§impl AddAssign<&Fraction> for Fraction
impl AddAssign<&Fraction> for Fraction
source§fn add_assign(&mut self, other: &Fraction)
fn add_assign(&mut self, other: &Fraction)
Performs the
+=
operation. Read moresource§impl AddAssign<&i32> for Fraction
impl AddAssign<&i32> for Fraction
source§fn add_assign(&mut self, other: &i32)
fn add_assign(&mut self, other: &i32)
Performs the
+=
operation. Read moresource§impl AddAssign<i32> for Fraction
impl AddAssign<i32> for Fraction
source§fn add_assign(&mut self, other: i32)
fn add_assign(&mut self, other: i32)
Performs the
+=
operation. Read moresource§impl AddAssign for Fraction
impl AddAssign for Fraction
source§fn add_assign(&mut self, other: Fraction)
fn add_assign(&mut self, other: Fraction)
Performs the
+=
operation. Read moresource§impl AsRef<Ratio<i32>> for Fraction
impl AsRef<Ratio<i32>> for Fraction
source§fn as_ref(&self) -> &Rational32
fn as_ref(&self) -> &Rational32
Converts this type into a shared reference of the (usually inferred) input type.
source§impl DerefMut for Fraction
impl DerefMut for Fraction
source§fn deref_mut(&mut self) -> &mut Rational32
fn deref_mut(&mut self) -> &mut Rational32
Mutably dereferences the value.
source§impl<'de> Deserialize<'de> for Fraction
impl<'de> Deserialize<'de> for Fraction
source§fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error>
fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error>
Deserialize this value from the given Serde deserializer. Read more
source§impl DivAssign<&Fraction> for Fraction
impl DivAssign<&Fraction> for Fraction
source§fn div_assign(&mut self, other: &Fraction)
fn div_assign(&mut self, other: &Fraction)
Performs the
/=
operation. Read moresource§impl DivAssign<&i32> for Fraction
impl DivAssign<&i32> for Fraction
source§fn div_assign(&mut self, other: &i32)
fn div_assign(&mut self, other: &i32)
Performs the
/=
operation. Read moresource§impl DivAssign<i32> for Fraction
impl DivAssign<i32> for Fraction
source§fn div_assign(&mut self, other: i32)
fn div_assign(&mut self, other: i32)
Performs the
/=
operation. Read moresource§impl DivAssign for Fraction
impl DivAssign for Fraction
source§fn div_assign(&mut self, other: Fraction)
fn div_assign(&mut self, other: Fraction)
Performs the
/=
operation. Read moresource§impl From<Fraction> for Rational32
impl From<Fraction> for Rational32
source§impl From<Ratio<i32>> for Fraction
impl From<Ratio<i32>> for Fraction
source§fn from(x: Rational32) -> Self
fn from(x: Rational32) -> Self
Converts to this type from the input type.
source§impl<'a> FromValue<'a> for Fraction
impl<'a> FromValue<'a> for Fraction
§type Checker = GenericValueTypeChecker<Fraction>
type Checker = GenericValueTypeChecker<Fraction>
Value type checker.
source§unsafe fn from_value(value: &'a Value) -> Self
unsafe fn from_value(value: &'a Value) -> Self
Get the contained value from a
Value
. Read moresource§impl HasParamSpec for Fraction
impl HasParamSpec for Fraction
type ParamSpec = ParamSpecFraction
type BuilderFn = for<'a> fn(_: &'a str) -> ParamSpecFractionBuilder<'a>
fn param_spec_builder() -> Self::BuilderFn
source§impl MulAssign<&Fraction> for Fraction
impl MulAssign<&Fraction> for Fraction
source§fn mul_assign(&mut self, other: &Fraction)
fn mul_assign(&mut self, other: &Fraction)
Performs the
*=
operation. Read moresource§impl MulAssign<&i32> for Fraction
impl MulAssign<&i32> for Fraction
source§fn mul_assign(&mut self, other: &i32)
fn mul_assign(&mut self, other: &i32)
Performs the
*=
operation. Read moresource§impl MulAssign<i32> for Fraction
impl MulAssign<i32> for Fraction
source§fn mul_assign(&mut self, other: i32)
fn mul_assign(&mut self, other: i32)
Performs the
*=
operation. Read moresource§impl MulAssign for Fraction
impl MulAssign for Fraction
source§fn mul_assign(&mut self, other: Fraction)
fn mul_assign(&mut self, other: Fraction)
Performs the
*=
operation. Read moresource§impl Ord for Fraction
impl Ord for Fraction
source§impl PartialEq for Fraction
impl PartialEq for Fraction
source§impl PartialOrd for Fraction
impl PartialOrd for Fraction
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 RemAssign<&Fraction> for Fraction
impl RemAssign<&Fraction> for Fraction
source§fn rem_assign(&mut self, other: &Fraction)
fn rem_assign(&mut self, other: &Fraction)
Performs the
%=
operation. Read moresource§impl RemAssign<&i32> for Fraction
impl RemAssign<&i32> for Fraction
source§fn rem_assign(&mut self, other: &i32)
fn rem_assign(&mut self, other: &i32)
Performs the
%=
operation. Read moresource§impl RemAssign<i32> for Fraction
impl RemAssign<i32> for Fraction
source§fn rem_assign(&mut self, other: i32)
fn rem_assign(&mut self, other: i32)
Performs the
%=
operation. Read moresource§impl RemAssign for Fraction
impl RemAssign for Fraction
source§fn rem_assign(&mut self, other: Fraction)
fn rem_assign(&mut self, other: Fraction)
Performs the
%=
operation. Read moresource§impl StaticType for Fraction
impl StaticType for Fraction
source§fn static_type() -> Type
fn static_type() -> Type
Returns the type identifier of
Self
.source§impl SubAssign<&Fraction> for Fraction
impl SubAssign<&Fraction> for Fraction
source§fn sub_assign(&mut self, other: &Fraction)
fn sub_assign(&mut self, other: &Fraction)
Performs the
-=
operation. Read moresource§impl SubAssign<&i32> for Fraction
impl SubAssign<&i32> for Fraction
source§fn sub_assign(&mut self, other: &i32)
fn sub_assign(&mut self, other: &i32)
Performs the
-=
operation. Read moresource§impl SubAssign<i32> for Fraction
impl SubAssign<i32> for Fraction
source§fn sub_assign(&mut self, other: i32)
fn sub_assign(&mut self, other: i32)
Performs the
-=
operation. Read moresource§impl SubAssign for Fraction
impl SubAssign for Fraction
source§fn sub_assign(&mut self, other: Fraction)
fn sub_assign(&mut self, other: Fraction)
Performs the
-=
operation. Read moreimpl Copy for Fraction
impl Eq for Fraction
impl StructuralPartialEq for Fraction
Auto Trait Implementations§
impl Freeze for Fraction
impl RefUnwindSafe for Fraction
impl Send for Fraction
impl Sync for Fraction
impl Unpin for Fraction
impl UnwindSafe for Fraction
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: Copy,
impl<T> CloneToUninit for Twhere
T: Copy,
source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
🔬This is a nightly-only experimental API. (
clone_to_uninit
)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
)source§impl<T> IntoClosureReturnValue for T
impl<T> IntoClosureReturnValue for T
fn into_closure_return_value(self) -> Option<Value>
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 moresource§impl<T> PropertyGet for Twhere
T: HasParamSpec,
impl<T> PropertyGet for Twhere
T: HasParamSpec,
source§impl<T> StaticTypeExt for Twhere
T: StaticType,
impl<T> StaticTypeExt for Twhere
T: StaticType,
source§fn ensure_type()
fn ensure_type()
Ensures that the type has been registered with the type system.
source§impl<T> ToSendValue for T
impl<T> ToSendValue for T
source§fn to_send_value(&self) -> SendValue
fn to_send_value(&self) -> SendValue
Returns a
SendValue
clone of self
.