pub struct Ratio<T> { /* private fields */ }Expand description
Represents the ratio between two numbers.
Implementations§
Source§impl<T> Ratio<T>
These method are const.
impl<T> Ratio<T>
These method are const.
Source§impl<T: Clone + Integer> Ratio<T>
impl<T: Clone + Integer> Ratio<T>
Sourcepub fn from_integer(t: T) -> Ratio<T>
pub fn from_integer(t: T) -> Ratio<T>
Creates a Ratio representing the integer t.
Sourcepub fn to_integer(&self) -> T
pub fn to_integer(&self) -> T
Converts to an integer, rounding towards zero.
Sourcepub fn is_integer(&self) -> bool
pub fn is_integer(&self) -> bool
Returns true if the rational number is an integer (denominator is 1).
Sourcepub fn reduced(&self) -> Ratio<T>
pub fn reduced(&self) -> Ratio<T>
Returns a reduced copy of self.
In general, it is not necessary to use this method, as the only
method of procuring a non-reduced fraction is through new_raw.
Panics if denom is zero.
Sourcepub fn round(&self) -> Ratio<T>
pub fn round(&self) -> Ratio<T>
Rounds to the nearest integer. Rounds half-way cases away from zero.
Source§impl Ratio<BigInt>
impl Ratio<BigInt>
Sourcepub fn from_float<T: FloatCore>(f: T) -> Option<BigRational>
pub fn from_float<T: FloatCore>(f: T) -> Option<BigRational>
Converts a float into a rational number.
Trait Implementations§
Source§impl<'a, T: Clone + Integer + NumAssign> AddAssign<&'a Ratio<T>> for Ratio<T>
impl<'a, T: Clone + Integer + NumAssign> AddAssign<&'a Ratio<T>> for Ratio<T>
Source§fn add_assign(&mut self, other: &Ratio<T>)
fn add_assign(&mut self, other: &Ratio<T>)
Performs the
+= operation. Read moreSource§impl<'a, T: Clone + Integer + NumAssign> AddAssign<&'a T> for Ratio<T>
impl<'a, T: Clone + Integer + NumAssign> AddAssign<&'a T> for Ratio<T>
Source§fn add_assign(&mut self, other: &T)
fn add_assign(&mut self, other: &T)
Performs the
+= operation. Read moreSource§impl<T: Clone + Integer + NumAssign> AddAssign<T> for Ratio<T>
impl<T: Clone + Integer + NumAssign> AddAssign<T> for Ratio<T>
Source§fn add_assign(&mut self, other: T)
fn add_assign(&mut self, other: T)
Performs the
+= operation. Read moreSource§impl<T: Clone + Integer + NumAssign> AddAssign for Ratio<T>
impl<T: Clone + Integer + NumAssign> AddAssign for Ratio<T>
Source§fn add_assign(&mut self, other: Ratio<T>)
fn add_assign(&mut self, other: Ratio<T>)
Performs the
+= operation. Read moreSource§impl<T: Clone + Integer + CheckedMul + CheckedAdd> CheckedAdd for Ratio<T>
impl<T: Clone + Integer + CheckedMul + CheckedAdd> CheckedAdd for Ratio<T>
Source§impl<T> CheckedDiv for Ratio<T>
impl<T> CheckedDiv for Ratio<T>
Source§impl<T> CheckedMul for Ratio<T>
impl<T> CheckedMul for Ratio<T>
Source§impl<T: Clone + Integer + CheckedMul + CheckedSub> CheckedSub for Ratio<T>
impl<T: Clone + Integer + CheckedMul + CheckedSub> CheckedSub for Ratio<T>
Source§impl<'a, T: Clone + Integer + NumAssign> DivAssign<&'a Ratio<T>> for Ratio<T>
impl<'a, T: Clone + Integer + NumAssign> DivAssign<&'a Ratio<T>> for Ratio<T>
Source§fn div_assign(&mut self, other: &Ratio<T>)
fn div_assign(&mut self, other: &Ratio<T>)
Performs the
/= operation. Read moreSource§impl<'a, T: Clone + Integer + NumAssign> DivAssign<&'a T> for Ratio<T>
impl<'a, T: Clone + Integer + NumAssign> DivAssign<&'a T> for Ratio<T>
Source§fn div_assign(&mut self, other: &T)
fn div_assign(&mut self, other: &T)
Performs the
/= operation. Read moreSource§impl<T: Clone + Integer + NumAssign> DivAssign<T> for Ratio<T>
impl<T: Clone + Integer + NumAssign> DivAssign<T> for Ratio<T>
Source§fn div_assign(&mut self, other: T)
fn div_assign(&mut self, other: T)
Performs the
/= operation. Read moreSource§impl<T: Clone + Integer + NumAssign> DivAssign for Ratio<T>
impl<T: Clone + Integer + NumAssign> DivAssign for Ratio<T>
Source§fn div_assign(&mut self, other: Ratio<T>)
fn div_assign(&mut self, other: Ratio<T>)
Performs the
/= operation. Read moreSource§impl FromPrimitive for Ratio<BigInt>
impl FromPrimitive for Ratio<BigInt>
Source§fn from_i64(n: i64) -> Option<Self>
fn from_i64(n: i64) -> Option<Self>
Converts an
i64 to return an optional value of this type. If the
value cannot be represented by this type, then None is returned.Source§fn from_i128(n: i128) -> Option<Self>
fn from_i128(n: i128) -> Option<Self>
Converts an
i128 to return an optional value of this type. If the
value cannot be represented by this type, then None is returned. Read moreSource§fn from_u64(n: u64) -> Option<Self>
fn from_u64(n: u64) -> Option<Self>
Converts an
u64 to return an optional value of this type. If the
value cannot be represented by this type, then None is returned.Source§fn from_u128(n: u128) -> Option<Self>
fn from_u128(n: u128) -> Option<Self>
Converts an
u128 to return an optional value of this type. If the
value cannot be represented by this type, then None is returned. Read moreSource§fn from_f32(n: f32) -> Option<Self>
fn from_f32(n: f32) -> Option<Self>
Converts a
f32 to return an optional value of this type. If the
value cannot be represented by this type, then None is returned.Source§fn from_f64(n: f64) -> Option<Self>
fn from_f64(n: f64) -> Option<Self>
Converts a
f64 to return an optional value of this type. If the
value cannot be represented by this type, then None is returned. Read moreSource§fn from_isize(n: isize) -> Option<Self>
fn from_isize(n: isize) -> Option<Self>
Converts an
isize to return an optional value of this type. If the
value cannot be represented by this type, then None is returned.Source§fn from_i8(n: i8) -> Option<Self>
fn from_i8(n: i8) -> Option<Self>
Converts an
i8 to return an optional value of this type. If the
value cannot be represented by this type, then None is returned.Source§fn from_i16(n: i16) -> Option<Self>
fn from_i16(n: i16) -> Option<Self>
Converts an
i16 to return an optional value of this type. If the
value cannot be represented by this type, then None is returned.Source§fn from_i32(n: i32) -> Option<Self>
fn from_i32(n: i32) -> Option<Self>
Converts an
i32 to return an optional value of this type. If the
value cannot be represented by this type, then None is returned.Source§fn from_usize(n: usize) -> Option<Self>
fn from_usize(n: usize) -> Option<Self>
Converts a
usize to return an optional value of this type. If the
value cannot be represented by this type, then None is returned.Source§fn from_u8(n: u8) -> Option<Self>
fn from_u8(n: u8) -> Option<Self>
Converts an
u8 to return an optional value of this type. If the
value cannot be represented by this type, then None is returned.Source§impl FromPrimitive for Ratio<i128>
impl FromPrimitive for Ratio<i128>
Source§fn from_i64(n: i64) -> Option<Self>
fn from_i64(n: i64) -> Option<Self>
Converts an
i64 to return an optional value of this type. If the
value cannot be represented by this type, then None is returned.Source§fn from_i128(n: i128) -> Option<Self>
fn from_i128(n: i128) -> Option<Self>
Converts an
i128 to return an optional value of this type. If the
value cannot be represented by this type, then None is returned. Read moreSource§fn from_u64(n: u64) -> Option<Self>
fn from_u64(n: u64) -> Option<Self>
Converts an
u64 to return an optional value of this type. If the
value cannot be represented by this type, then None is returned.Source§fn from_u128(n: u128) -> Option<Self>
fn from_u128(n: u128) -> Option<Self>
Converts an
u128 to return an optional value of this type. If the
value cannot be represented by this type, then None is returned. Read moreSource§fn from_f32(n: f32) -> Option<Self>
fn from_f32(n: f32) -> Option<Self>
Converts a
f32 to return an optional value of this type. If the
value cannot be represented by this type, then None is returned.Source§fn from_f64(n: f64) -> Option<Self>
fn from_f64(n: f64) -> Option<Self>
Converts a
f64 to return an optional value of this type. If the
value cannot be represented by this type, then None is returned. Read moreSource§fn from_isize(n: isize) -> Option<Self>
fn from_isize(n: isize) -> Option<Self>
Converts an
isize to return an optional value of this type. If the
value cannot be represented by this type, then None is returned.Source§fn from_i8(n: i8) -> Option<Self>
fn from_i8(n: i8) -> Option<Self>
Converts an
i8 to return an optional value of this type. If the
value cannot be represented by this type, then None is returned.Source§fn from_i16(n: i16) -> Option<Self>
fn from_i16(n: i16) -> Option<Self>
Converts an
i16 to return an optional value of this type. If the
value cannot be represented by this type, then None is returned.Source§fn from_i32(n: i32) -> Option<Self>
fn from_i32(n: i32) -> Option<Self>
Converts an
i32 to return an optional value of this type. If the
value cannot be represented by this type, then None is returned.Source§fn from_usize(n: usize) -> Option<Self>
fn from_usize(n: usize) -> Option<Self>
Converts a
usize to return an optional value of this type. If the
value cannot be represented by this type, then None is returned.Source§fn from_u8(n: u8) -> Option<Self>
fn from_u8(n: u8) -> Option<Self>
Converts an
u8 to return an optional value of this type. If the
value cannot be represented by this type, then None is returned.Source§impl FromPrimitive for Ratio<i16>
impl FromPrimitive for Ratio<i16>
Source§fn from_i64(n: i64) -> Option<Self>
fn from_i64(n: i64) -> Option<Self>
Converts an
i64 to return an optional value of this type. If the
value cannot be represented by this type, then None is returned.Source§fn from_i128(n: i128) -> Option<Self>
fn from_i128(n: i128) -> Option<Self>
Converts an
i128 to return an optional value of this type. If the
value cannot be represented by this type, then None is returned. Read moreSource§fn from_u64(n: u64) -> Option<Self>
fn from_u64(n: u64) -> Option<Self>
Converts an
u64 to return an optional value of this type. If the
value cannot be represented by this type, then None is returned.Source§fn from_u128(n: u128) -> Option<Self>
fn from_u128(n: u128) -> Option<Self>
Converts an
u128 to return an optional value of this type. If the
value cannot be represented by this type, then None is returned. Read moreSource§fn from_f32(n: f32) -> Option<Self>
fn from_f32(n: f32) -> Option<Self>
Converts a
f32 to return an optional value of this type. If the
value cannot be represented by this type, then None is returned.Source§fn from_f64(n: f64) -> Option<Self>
fn from_f64(n: f64) -> Option<Self>
Converts a
f64 to return an optional value of this type. If the
value cannot be represented by this type, then None is returned. Read moreSource§fn from_isize(n: isize) -> Option<Self>
fn from_isize(n: isize) -> Option<Self>
Converts an
isize to return an optional value of this type. If the
value cannot be represented by this type, then None is returned.Source§fn from_i8(n: i8) -> Option<Self>
fn from_i8(n: i8) -> Option<Self>
Converts an
i8 to return an optional value of this type. If the
value cannot be represented by this type, then None is returned.Source§fn from_i16(n: i16) -> Option<Self>
fn from_i16(n: i16) -> Option<Self>
Converts an
i16 to return an optional value of this type. If the
value cannot be represented by this type, then None is returned.Source§fn from_i32(n: i32) -> Option<Self>
fn from_i32(n: i32) -> Option<Self>
Converts an
i32 to return an optional value of this type. If the
value cannot be represented by this type, then None is returned.Source§fn from_usize(n: usize) -> Option<Self>
fn from_usize(n: usize) -> Option<Self>
Converts a
usize to return an optional value of this type. If the
value cannot be represented by this type, then None is returned.Source§fn from_u8(n: u8) -> Option<Self>
fn from_u8(n: u8) -> Option<Self>
Converts an
u8 to return an optional value of this type. If the
value cannot be represented by this type, then None is returned.Source§impl FromPrimitive for Ratio<i32>
impl FromPrimitive for Ratio<i32>
Source§fn from_i64(n: i64) -> Option<Self>
fn from_i64(n: i64) -> Option<Self>
Converts an
i64 to return an optional value of this type. If the
value cannot be represented by this type, then None is returned.Source§fn from_i128(n: i128) -> Option<Self>
fn from_i128(n: i128) -> Option<Self>
Converts an
i128 to return an optional value of this type. If the
value cannot be represented by this type, then None is returned. Read moreSource§fn from_u64(n: u64) -> Option<Self>
fn from_u64(n: u64) -> Option<Self>
Converts an
u64 to return an optional value of this type. If the
value cannot be represented by this type, then None is returned.Source§fn from_u128(n: u128) -> Option<Self>
fn from_u128(n: u128) -> Option<Self>
Converts an
u128 to return an optional value of this type. If the
value cannot be represented by this type, then None is returned. Read moreSource§fn from_f32(n: f32) -> Option<Self>
fn from_f32(n: f32) -> Option<Self>
Converts a
f32 to return an optional value of this type. If the
value cannot be represented by this type, then None is returned.Source§fn from_f64(n: f64) -> Option<Self>
fn from_f64(n: f64) -> Option<Self>
Converts a
f64 to return an optional value of this type. If the
value cannot be represented by this type, then None is returned. Read moreSource§fn from_isize(n: isize) -> Option<Self>
fn from_isize(n: isize) -> Option<Self>
Converts an
isize to return an optional value of this type. If the
value cannot be represented by this type, then None is returned.Source§fn from_i8(n: i8) -> Option<Self>
fn from_i8(n: i8) -> Option<Self>
Converts an
i8 to return an optional value of this type. If the
value cannot be represented by this type, then None is returned.Source§fn from_i16(n: i16) -> Option<Self>
fn from_i16(n: i16) -> Option<Self>
Converts an
i16 to return an optional value of this type. If the
value cannot be represented by this type, then None is returned.Source§fn from_i32(n: i32) -> Option<Self>
fn from_i32(n: i32) -> Option<Self>
Converts an
i32 to return an optional value of this type. If the
value cannot be represented by this type, then None is returned.Source§fn from_usize(n: usize) -> Option<Self>
fn from_usize(n: usize) -> Option<Self>
Converts a
usize to return an optional value of this type. If the
value cannot be represented by this type, then None is returned.Source§fn from_u8(n: u8) -> Option<Self>
fn from_u8(n: u8) -> Option<Self>
Converts an
u8 to return an optional value of this type. If the
value cannot be represented by this type, then None is returned.Source§impl FromPrimitive for Ratio<i64>
impl FromPrimitive for Ratio<i64>
Source§fn from_i64(n: i64) -> Option<Self>
fn from_i64(n: i64) -> Option<Self>
Converts an
i64 to return an optional value of this type. If the
value cannot be represented by this type, then None is returned.Source§fn from_i128(n: i128) -> Option<Self>
fn from_i128(n: i128) -> Option<Self>
Converts an
i128 to return an optional value of this type. If the
value cannot be represented by this type, then None is returned. Read moreSource§fn from_u64(n: u64) -> Option<Self>
fn from_u64(n: u64) -> Option<Self>
Converts an
u64 to return an optional value of this type. If the
value cannot be represented by this type, then None is returned.Source§fn from_u128(n: u128) -> Option<Self>
fn from_u128(n: u128) -> Option<Self>
Converts an
u128 to return an optional value of this type. If the
value cannot be represented by this type, then None is returned. Read moreSource§fn from_f32(n: f32) -> Option<Self>
fn from_f32(n: f32) -> Option<Self>
Converts a
f32 to return an optional value of this type. If the
value cannot be represented by this type, then None is returned.Source§fn from_f64(n: f64) -> Option<Self>
fn from_f64(n: f64) -> Option<Self>
Converts a
f64 to return an optional value of this type. If the
value cannot be represented by this type, then None is returned. Read moreSource§fn from_isize(n: isize) -> Option<Self>
fn from_isize(n: isize) -> Option<Self>
Converts an
isize to return an optional value of this type. If the
value cannot be represented by this type, then None is returned.Source§fn from_i8(n: i8) -> Option<Self>
fn from_i8(n: i8) -> Option<Self>
Converts an
i8 to return an optional value of this type. If the
value cannot be represented by this type, then None is returned.Source§fn from_i16(n: i16) -> Option<Self>
fn from_i16(n: i16) -> Option<Self>
Converts an
i16 to return an optional value of this type. If the
value cannot be represented by this type, then None is returned.Source§fn from_i32(n: i32) -> Option<Self>
fn from_i32(n: i32) -> Option<Self>
Converts an
i32 to return an optional value of this type. If the
value cannot be represented by this type, then None is returned.Source§fn from_usize(n: usize) -> Option<Self>
fn from_usize(n: usize) -> Option<Self>
Converts a
usize to return an optional value of this type. If the
value cannot be represented by this type, then None is returned.Source§fn from_u8(n: u8) -> Option<Self>
fn from_u8(n: u8) -> Option<Self>
Converts an
u8 to return an optional value of this type. If the
value cannot be represented by this type, then None is returned.Source§impl FromPrimitive for Ratio<i8>
impl FromPrimitive for Ratio<i8>
Source§fn from_i64(n: i64) -> Option<Self>
fn from_i64(n: i64) -> Option<Self>
Converts an
i64 to return an optional value of this type. If the
value cannot be represented by this type, then None is returned.Source§fn from_i128(n: i128) -> Option<Self>
fn from_i128(n: i128) -> Option<Self>
Converts an
i128 to return an optional value of this type. If the
value cannot be represented by this type, then None is returned. Read moreSource§fn from_u64(n: u64) -> Option<Self>
fn from_u64(n: u64) -> Option<Self>
Converts an
u64 to return an optional value of this type. If the
value cannot be represented by this type, then None is returned.Source§fn from_u128(n: u128) -> Option<Self>
fn from_u128(n: u128) -> Option<Self>
Converts an
u128 to return an optional value of this type. If the
value cannot be represented by this type, then None is returned. Read moreSource§fn from_f32(n: f32) -> Option<Self>
fn from_f32(n: f32) -> Option<Self>
Converts a
f32 to return an optional value of this type. If the
value cannot be represented by this type, then None is returned.Source§fn from_f64(n: f64) -> Option<Self>
fn from_f64(n: f64) -> Option<Self>
Converts a
f64 to return an optional value of this type. If the
value cannot be represented by this type, then None is returned. Read moreSource§fn from_isize(n: isize) -> Option<Self>
fn from_isize(n: isize) -> Option<Self>
Converts an
isize to return an optional value of this type. If the
value cannot be represented by this type, then None is returned.Source§fn from_i8(n: i8) -> Option<Self>
fn from_i8(n: i8) -> Option<Self>
Converts an
i8 to return an optional value of this type. If the
value cannot be represented by this type, then None is returned.Source§fn from_i16(n: i16) -> Option<Self>
fn from_i16(n: i16) -> Option<Self>
Converts an
i16 to return an optional value of this type. If the
value cannot be represented by this type, then None is returned.Source§fn from_i32(n: i32) -> Option<Self>
fn from_i32(n: i32) -> Option<Self>
Converts an
i32 to return an optional value of this type. If the
value cannot be represented by this type, then None is returned.Source§fn from_usize(n: usize) -> Option<Self>
fn from_usize(n: usize) -> Option<Self>
Converts a
usize to return an optional value of this type. If the
value cannot be represented by this type, then None is returned.Source§fn from_u8(n: u8) -> Option<Self>
fn from_u8(n: u8) -> Option<Self>
Converts an
u8 to return an optional value of this type. If the
value cannot be represented by this type, then None is returned.Source§impl FromPrimitive for Ratio<isize>
impl FromPrimitive for Ratio<isize>
Source§fn from_i64(n: i64) -> Option<Self>
fn from_i64(n: i64) -> Option<Self>
Converts an
i64 to return an optional value of this type. If the
value cannot be represented by this type, then None is returned.Source§fn from_i128(n: i128) -> Option<Self>
fn from_i128(n: i128) -> Option<Self>
Converts an
i128 to return an optional value of this type. If the
value cannot be represented by this type, then None is returned. Read moreSource§fn from_u64(n: u64) -> Option<Self>
fn from_u64(n: u64) -> Option<Self>
Converts an
u64 to return an optional value of this type. If the
value cannot be represented by this type, then None is returned.Source§fn from_u128(n: u128) -> Option<Self>
fn from_u128(n: u128) -> Option<Self>
Converts an
u128 to return an optional value of this type. If the
value cannot be represented by this type, then None is returned. Read moreSource§fn from_f32(n: f32) -> Option<Self>
fn from_f32(n: f32) -> Option<Self>
Converts a
f32 to return an optional value of this type. If the
value cannot be represented by this type, then None is returned.Source§fn from_f64(n: f64) -> Option<Self>
fn from_f64(n: f64) -> Option<Self>
Converts a
f64 to return an optional value of this type. If the
value cannot be represented by this type, then None is returned. Read moreSource§fn from_isize(n: isize) -> Option<Self>
fn from_isize(n: isize) -> Option<Self>
Converts an
isize to return an optional value of this type. If the
value cannot be represented by this type, then None is returned.Source§fn from_i8(n: i8) -> Option<Self>
fn from_i8(n: i8) -> Option<Self>
Converts an
i8 to return an optional value of this type. If the
value cannot be represented by this type, then None is returned.Source§fn from_i16(n: i16) -> Option<Self>
fn from_i16(n: i16) -> Option<Self>
Converts an
i16 to return an optional value of this type. If the
value cannot be represented by this type, then None is returned.Source§fn from_i32(n: i32) -> Option<Self>
fn from_i32(n: i32) -> Option<Self>
Converts an
i32 to return an optional value of this type. If the
value cannot be represented by this type, then None is returned.Source§fn from_usize(n: usize) -> Option<Self>
fn from_usize(n: usize) -> Option<Self>
Converts a
usize to return an optional value of this type. If the
value cannot be represented by this type, then None is returned.Source§fn from_u8(n: u8) -> Option<Self>
fn from_u8(n: u8) -> Option<Self>
Converts an
u8 to return an optional value of this type. If the
value cannot be represented by this type, then None is returned.Source§impl FromPrimitive for Ratio<u128>
impl FromPrimitive for Ratio<u128>
Source§fn from_i64(n: i64) -> Option<Self>
fn from_i64(n: i64) -> Option<Self>
Converts an
i64 to return an optional value of this type. If the
value cannot be represented by this type, then None is returned.Source§fn from_i128(n: i128) -> Option<Self>
fn from_i128(n: i128) -> Option<Self>
Converts an
i128 to return an optional value of this type. If the
value cannot be represented by this type, then None is returned. Read moreSource§fn from_u64(n: u64) -> Option<Self>
fn from_u64(n: u64) -> Option<Self>
Converts an
u64 to return an optional value of this type. If the
value cannot be represented by this type, then None is returned.Source§fn from_u128(n: u128) -> Option<Self>
fn from_u128(n: u128) -> Option<Self>
Converts an
u128 to return an optional value of this type. If the
value cannot be represented by this type, then None is returned. Read moreSource§fn from_f32(n: f32) -> Option<Self>
fn from_f32(n: f32) -> Option<Self>
Converts a
f32 to return an optional value of this type. If the
value cannot be represented by this type, then None is returned.Source§fn from_f64(n: f64) -> Option<Self>
fn from_f64(n: f64) -> Option<Self>
Converts a
f64 to return an optional value of this type. If the
value cannot be represented by this type, then None is returned. Read moreSource§fn from_isize(n: isize) -> Option<Self>
fn from_isize(n: isize) -> Option<Self>
Converts an
isize to return an optional value of this type. If the
value cannot be represented by this type, then None is returned.Source§fn from_i8(n: i8) -> Option<Self>
fn from_i8(n: i8) -> Option<Self>
Converts an
i8 to return an optional value of this type. If the
value cannot be represented by this type, then None is returned.Source§fn from_i16(n: i16) -> Option<Self>
fn from_i16(n: i16) -> Option<Self>
Converts an
i16 to return an optional value of this type. If the
value cannot be represented by this type, then None is returned.Source§fn from_i32(n: i32) -> Option<Self>
fn from_i32(n: i32) -> Option<Self>
Converts an
i32 to return an optional value of this type. If the
value cannot be represented by this type, then None is returned.Source§fn from_usize(n: usize) -> Option<Self>
fn from_usize(n: usize) -> Option<Self>
Converts a
usize to return an optional value of this type. If the
value cannot be represented by this type, then None is returned.Source§fn from_u8(n: u8) -> Option<Self>
fn from_u8(n: u8) -> Option<Self>
Converts an
u8 to return an optional value of this type. If the
value cannot be represented by this type, then None is returned.Source§impl FromPrimitive for Ratio<u16>
impl FromPrimitive for Ratio<u16>
Source§fn from_i64(n: i64) -> Option<Self>
fn from_i64(n: i64) -> Option<Self>
Converts an
i64 to return an optional value of this type. If the
value cannot be represented by this type, then None is returned.Source§fn from_i128(n: i128) -> Option<Self>
fn from_i128(n: i128) -> Option<Self>
Converts an
i128 to return an optional value of this type. If the
value cannot be represented by this type, then None is returned. Read moreSource§fn from_u64(n: u64) -> Option<Self>
fn from_u64(n: u64) -> Option<Self>
Converts an
u64 to return an optional value of this type. If the
value cannot be represented by this type, then None is returned.Source§fn from_u128(n: u128) -> Option<Self>
fn from_u128(n: u128) -> Option<Self>
Converts an
u128 to return an optional value of this type. If the
value cannot be represented by this type, then None is returned. Read moreSource§fn from_f32(n: f32) -> Option<Self>
fn from_f32(n: f32) -> Option<Self>
Converts a
f32 to return an optional value of this type. If the
value cannot be represented by this type, then None is returned.Source§fn from_f64(n: f64) -> Option<Self>
fn from_f64(n: f64) -> Option<Self>
Converts a
f64 to return an optional value of this type. If the
value cannot be represented by this type, then None is returned. Read moreSource§fn from_isize(n: isize) -> Option<Self>
fn from_isize(n: isize) -> Option<Self>
Converts an
isize to return an optional value of this type. If the
value cannot be represented by this type, then None is returned.Source§fn from_i8(n: i8) -> Option<Self>
fn from_i8(n: i8) -> Option<Self>
Converts an
i8 to return an optional value of this type. If the
value cannot be represented by this type, then None is returned.Source§fn from_i16(n: i16) -> Option<Self>
fn from_i16(n: i16) -> Option<Self>
Converts an
i16 to return an optional value of this type. If the
value cannot be represented by this type, then None is returned.Source§fn from_i32(n: i32) -> Option<Self>
fn from_i32(n: i32) -> Option<Self>
Converts an
i32 to return an optional value of this type. If the
value cannot be represented by this type, then None is returned.Source§fn from_usize(n: usize) -> Option<Self>
fn from_usize(n: usize) -> Option<Self>
Converts a
usize to return an optional value of this type. If the
value cannot be represented by this type, then None is returned.Source§fn from_u8(n: u8) -> Option<Self>
fn from_u8(n: u8) -> Option<Self>
Converts an
u8 to return an optional value of this type. If the
value cannot be represented by this type, then None is returned.Source§impl FromPrimitive for Ratio<u32>
impl FromPrimitive for Ratio<u32>
Source§fn from_i64(n: i64) -> Option<Self>
fn from_i64(n: i64) -> Option<Self>
Converts an
i64 to return an optional value of this type. If the
value cannot be represented by this type, then None is returned.Source§fn from_i128(n: i128) -> Option<Self>
fn from_i128(n: i128) -> Option<Self>
Converts an
i128 to return an optional value of this type. If the
value cannot be represented by this type, then None is returned. Read moreSource§fn from_u64(n: u64) -> Option<Self>
fn from_u64(n: u64) -> Option<Self>
Converts an
u64 to return an optional value of this type. If the
value cannot be represented by this type, then None is returned.Source§fn from_u128(n: u128) -> Option<Self>
fn from_u128(n: u128) -> Option<Self>
Converts an
u128 to return an optional value of this type. If the
value cannot be represented by this type, then None is returned. Read moreSource§fn from_f32(n: f32) -> Option<Self>
fn from_f32(n: f32) -> Option<Self>
Converts a
f32 to return an optional value of this type. If the
value cannot be represented by this type, then None is returned.Source§fn from_f64(n: f64) -> Option<Self>
fn from_f64(n: f64) -> Option<Self>
Converts a
f64 to return an optional value of this type. If the
value cannot be represented by this type, then None is returned. Read moreSource§fn from_isize(n: isize) -> Option<Self>
fn from_isize(n: isize) -> Option<Self>
Converts an
isize to return an optional value of this type. If the
value cannot be represented by this type, then None is returned.Source§fn from_i8(n: i8) -> Option<Self>
fn from_i8(n: i8) -> Option<Self>
Converts an
i8 to return an optional value of this type. If the
value cannot be represented by this type, then None is returned.Source§fn from_i16(n: i16) -> Option<Self>
fn from_i16(n: i16) -> Option<Self>
Converts an
i16 to return an optional value of this type. If the
value cannot be represented by this type, then None is returned.Source§fn from_i32(n: i32) -> Option<Self>
fn from_i32(n: i32) -> Option<Self>
Converts an
i32 to return an optional value of this type. If the
value cannot be represented by this type, then None is returned.Source§fn from_usize(n: usize) -> Option<Self>
fn from_usize(n: usize) -> Option<Self>
Converts a
usize to return an optional value of this type. If the
value cannot be represented by this type, then None is returned.Source§fn from_u8(n: u8) -> Option<Self>
fn from_u8(n: u8) -> Option<Self>
Converts an
u8 to return an optional value of this type. If the
value cannot be represented by this type, then None is returned.Source§impl FromPrimitive for Ratio<u64>
impl FromPrimitive for Ratio<u64>
Source§fn from_i64(n: i64) -> Option<Self>
fn from_i64(n: i64) -> Option<Self>
Converts an
i64 to return an optional value of this type. If the
value cannot be represented by this type, then None is returned.Source§fn from_i128(n: i128) -> Option<Self>
fn from_i128(n: i128) -> Option<Self>
Converts an
i128 to return an optional value of this type. If the
value cannot be represented by this type, then None is returned. Read moreSource§fn from_u64(n: u64) -> Option<Self>
fn from_u64(n: u64) -> Option<Self>
Converts an
u64 to return an optional value of this type. If the
value cannot be represented by this type, then None is returned.Source§fn from_u128(n: u128) -> Option<Self>
fn from_u128(n: u128) -> Option<Self>
Converts an
u128 to return an optional value of this type. If the
value cannot be represented by this type, then None is returned. Read moreSource§fn from_f32(n: f32) -> Option<Self>
fn from_f32(n: f32) -> Option<Self>
Converts a
f32 to return an optional value of this type. If the
value cannot be represented by this type, then None is returned.Source§fn from_f64(n: f64) -> Option<Self>
fn from_f64(n: f64) -> Option<Self>
Converts a
f64 to return an optional value of this type. If the
value cannot be represented by this type, then None is returned. Read moreSource§fn from_isize(n: isize) -> Option<Self>
fn from_isize(n: isize) -> Option<Self>
Converts an
isize to return an optional value of this type. If the
value cannot be represented by this type, then None is returned.Source§fn from_i8(n: i8) -> Option<Self>
fn from_i8(n: i8) -> Option<Self>
Converts an
i8 to return an optional value of this type. If the
value cannot be represented by this type, then None is returned.Source§fn from_i16(n: i16) -> Option<Self>
fn from_i16(n: i16) -> Option<Self>
Converts an
i16 to return an optional value of this type. If the
value cannot be represented by this type, then None is returned.Source§fn from_i32(n: i32) -> Option<Self>
fn from_i32(n: i32) -> Option<Self>
Converts an
i32 to return an optional value of this type. If the
value cannot be represented by this type, then None is returned.Source§fn from_usize(n: usize) -> Option<Self>
fn from_usize(n: usize) -> Option<Self>
Converts a
usize to return an optional value of this type. If the
value cannot be represented by this type, then None is returned.Source§fn from_u8(n: u8) -> Option<Self>
fn from_u8(n: u8) -> Option<Self>
Converts an
u8 to return an optional value of this type. If the
value cannot be represented by this type, then None is returned.Source§impl FromPrimitive for Ratio<u8>
impl FromPrimitive for Ratio<u8>
Source§fn from_i64(n: i64) -> Option<Self>
fn from_i64(n: i64) -> Option<Self>
Converts an
i64 to return an optional value of this type. If the
value cannot be represented by this type, then None is returned.Source§fn from_i128(n: i128) -> Option<Self>
fn from_i128(n: i128) -> Option<Self>
Converts an
i128 to return an optional value of this type. If the
value cannot be represented by this type, then None is returned. Read moreSource§fn from_u64(n: u64) -> Option<Self>
fn from_u64(n: u64) -> Option<Self>
Converts an
u64 to return an optional value of this type. If the
value cannot be represented by this type, then None is returned.Source§fn from_u128(n: u128) -> Option<Self>
fn from_u128(n: u128) -> Option<Self>
Converts an
u128 to return an optional value of this type. If the
value cannot be represented by this type, then None is returned. Read moreSource§fn from_f32(n: f32) -> Option<Self>
fn from_f32(n: f32) -> Option<Self>
Converts a
f32 to return an optional value of this type. If the
value cannot be represented by this type, then None is returned.Source§fn from_f64(n: f64) -> Option<Self>
fn from_f64(n: f64) -> Option<Self>
Converts a
f64 to return an optional value of this type. If the
value cannot be represented by this type, then None is returned. Read moreSource§fn from_isize(n: isize) -> Option<Self>
fn from_isize(n: isize) -> Option<Self>
Converts an
isize to return an optional value of this type. If the
value cannot be represented by this type, then None is returned.Source§fn from_i8(n: i8) -> Option<Self>
fn from_i8(n: i8) -> Option<Self>
Converts an
i8 to return an optional value of this type. If the
value cannot be represented by this type, then None is returned.Source§fn from_i16(n: i16) -> Option<Self>
fn from_i16(n: i16) -> Option<Self>
Converts an
i16 to return an optional value of this type. If the
value cannot be represented by this type, then None is returned.Source§fn from_i32(n: i32) -> Option<Self>
fn from_i32(n: i32) -> Option<Self>
Converts an
i32 to return an optional value of this type. If the
value cannot be represented by this type, then None is returned.Source§fn from_usize(n: usize) -> Option<Self>
fn from_usize(n: usize) -> Option<Self>
Converts a
usize to return an optional value of this type. If the
value cannot be represented by this type, then None is returned.Source§fn from_u8(n: u8) -> Option<Self>
fn from_u8(n: u8) -> Option<Self>
Converts an
u8 to return an optional value of this type. If the
value cannot be represented by this type, then None is returned.Source§impl FromPrimitive for Ratio<usize>
impl FromPrimitive for Ratio<usize>
Source§fn from_i64(n: i64) -> Option<Self>
fn from_i64(n: i64) -> Option<Self>
Converts an
i64 to return an optional value of this type. If the
value cannot be represented by this type, then None is returned.Source§fn from_i128(n: i128) -> Option<Self>
fn from_i128(n: i128) -> Option<Self>
Converts an
i128 to return an optional value of this type. If the
value cannot be represented by this type, then None is returned. Read moreSource§fn from_u64(n: u64) -> Option<Self>
fn from_u64(n: u64) -> Option<Self>
Converts an
u64 to return an optional value of this type. If the
value cannot be represented by this type, then None is returned.Source§fn from_u128(n: u128) -> Option<Self>
fn from_u128(n: u128) -> Option<Self>
Converts an
u128 to return an optional value of this type. If the
value cannot be represented by this type, then None is returned. Read moreSource§fn from_f32(n: f32) -> Option<Self>
fn from_f32(n: f32) -> Option<Self>
Converts a
f32 to return an optional value of this type. If the
value cannot be represented by this type, then None is returned.Source§fn from_f64(n: f64) -> Option<Self>
fn from_f64(n: f64) -> Option<Self>
Converts a
f64 to return an optional value of this type. If the
value cannot be represented by this type, then None is returned. Read moreSource§fn from_isize(n: isize) -> Option<Self>
fn from_isize(n: isize) -> Option<Self>
Converts an
isize to return an optional value of this type. If the
value cannot be represented by this type, then None is returned.Source§fn from_i8(n: i8) -> Option<Self>
fn from_i8(n: i8) -> Option<Self>
Converts an
i8 to return an optional value of this type. If the
value cannot be represented by this type, then None is returned.Source§fn from_i16(n: i16) -> Option<Self>
fn from_i16(n: i16) -> Option<Self>
Converts an
i16 to return an optional value of this type. If the
value cannot be represented by this type, then None is returned.Source§fn from_i32(n: i32) -> Option<Self>
fn from_i32(n: i32) -> Option<Self>
Converts an
i32 to return an optional value of this type. If the
value cannot be represented by this type, then None is returned.Source§fn from_usize(n: usize) -> Option<Self>
fn from_usize(n: usize) -> Option<Self>
Converts a
usize to return an optional value of this type. If the
value cannot be represented by this type, then None is returned.Source§fn from_u8(n: u8) -> Option<Self>
fn from_u8(n: u8) -> Option<Self>
Converts an
u8 to return an optional value of this type. If the
value cannot be represented by this type, then None is returned.Source§impl<'a, T: Clone + Integer + NumAssign> MulAssign<&'a Ratio<T>> for Ratio<T>
impl<'a, T: Clone + Integer + NumAssign> MulAssign<&'a Ratio<T>> for Ratio<T>
Source§fn mul_assign(&mut self, other: &Ratio<T>)
fn mul_assign(&mut self, other: &Ratio<T>)
Performs the
*= operation. Read moreSource§impl<'a, T: Clone + Integer + NumAssign> MulAssign<&'a T> for Ratio<T>
impl<'a, T: Clone + Integer + NumAssign> MulAssign<&'a T> for Ratio<T>
Source§fn mul_assign(&mut self, other: &T)
fn mul_assign(&mut self, other: &T)
Performs the
*= operation. Read moreSource§impl<T: Clone + Integer + NumAssign> MulAssign<T> for Ratio<T>
impl<T: Clone + Integer + NumAssign> MulAssign<T> for Ratio<T>
Source§fn mul_assign(&mut self, other: T)
fn mul_assign(&mut self, other: T)
Performs the
*= operation. Read moreSource§impl<T: Clone + Integer + NumAssign> MulAssign for Ratio<T>
impl<T: Clone + Integer + NumAssign> MulAssign for Ratio<T>
Source§fn mul_assign(&mut self, other: Ratio<T>)
fn mul_assign(&mut self, other: Ratio<T>)
Performs the
*= operation. Read moreSource§impl<T: Clone + Integer> Num for Ratio<T>
impl<T: Clone + Integer> Num for Ratio<T>
Source§fn from_str_radix(s: &str, radix: u32) -> Result<Ratio<T>, ParseRatioError>
fn from_str_radix(s: &str, radix: u32) -> Result<Ratio<T>, ParseRatioError>
Parses numer/denom where the numbers are in base radix.
type FromStrRadixErr = ParseRatioError
Source§impl<T: Clone + Integer> Ord for Ratio<T>
impl<T: Clone + Integer> Ord for Ratio<T>
Source§impl<T: Clone + Integer> PartialOrd for Ratio<T>
impl<T: Clone + Integer> PartialOrd for Ratio<T>
Source§impl<'a, T: Clone + Integer + NumAssign> RemAssign<&'a Ratio<T>> for Ratio<T>
impl<'a, T: Clone + Integer + NumAssign> RemAssign<&'a Ratio<T>> for Ratio<T>
Source§fn rem_assign(&mut self, other: &Ratio<T>)
fn rem_assign(&mut self, other: &Ratio<T>)
Performs the
%= operation. Read moreSource§impl<'a, T: Clone + Integer + NumAssign> RemAssign<&'a T> for Ratio<T>
impl<'a, T: Clone + Integer + NumAssign> RemAssign<&'a T> for Ratio<T>
Source§fn rem_assign(&mut self, other: &T)
fn rem_assign(&mut self, other: &T)
Performs the
%= operation. Read moreSource§impl<T: Clone + Integer + NumAssign> RemAssign<T> for Ratio<T>
impl<T: Clone + Integer + NumAssign> RemAssign<T> for Ratio<T>
Source§fn rem_assign(&mut self, other: T)
fn rem_assign(&mut self, other: T)
Performs the
%= operation. Read moreSource§impl<T: Clone + Integer + NumAssign> RemAssign for Ratio<T>
impl<T: Clone + Integer + NumAssign> RemAssign for Ratio<T>
Source§fn rem_assign(&mut self, other: Ratio<T>)
fn rem_assign(&mut self, other: Ratio<T>)
Performs the
%= operation. Read moreSource§impl<T: Clone + Integer + Signed> Signed for Ratio<T>
impl<T: Clone + Integer + Signed> Signed for Ratio<T>
Source§fn abs_sub(&self, other: &Ratio<T>) -> Ratio<T>
fn abs_sub(&self, other: &Ratio<T>) -> Ratio<T>
The positive difference of two numbers. Read more
Source§fn is_positive(&self) -> bool
fn is_positive(&self) -> bool
Returns true if the number is positive and false if the number is zero or negative.
Source§fn is_negative(&self) -> bool
fn is_negative(&self) -> bool
Returns true if the number is negative and false if the number is zero or positive.
Source§impl<'a, T: Clone + Integer + NumAssign> SubAssign<&'a Ratio<T>> for Ratio<T>
impl<'a, T: Clone + Integer + NumAssign> SubAssign<&'a Ratio<T>> for Ratio<T>
Source§fn sub_assign(&mut self, other: &Ratio<T>)
fn sub_assign(&mut self, other: &Ratio<T>)
Performs the
-= operation. Read moreSource§impl<'a, T: Clone + Integer + NumAssign> SubAssign<&'a T> for Ratio<T>
impl<'a, T: Clone + Integer + NumAssign> SubAssign<&'a T> for Ratio<T>
Source§fn sub_assign(&mut self, other: &T)
fn sub_assign(&mut self, other: &T)
Performs the
-= operation. Read moreSource§impl<T: Clone + Integer + NumAssign> SubAssign<T> for Ratio<T>
impl<T: Clone + Integer + NumAssign> SubAssign<T> for Ratio<T>
Source§fn sub_assign(&mut self, other: T)
fn sub_assign(&mut self, other: T)
Performs the
-= operation. Read moreSource§impl<T: Clone + Integer + NumAssign> SubAssign for Ratio<T>
impl<T: Clone + Integer + NumAssign> SubAssign for Ratio<T>
Source§fn sub_assign(&mut self, other: Ratio<T>)
fn sub_assign(&mut self, other: Ratio<T>)
Performs the
-= operation. Read moreSource§impl<T: Clone + Integer + ToPrimitive + ToBigInt> ToPrimitive for Ratio<T>
impl<T: Clone + Integer + ToPrimitive + ToBigInt> ToPrimitive for Ratio<T>
Source§fn to_i64(&self) -> Option<i64>
fn to_i64(&self) -> Option<i64>
Converts the value of
self to an i64. If the value cannot be
represented by an i64, then None is returned.Source§fn to_i128(&self) -> Option<i128>
fn to_i128(&self) -> Option<i128>
Converts the value of
self to an i128. If the value cannot be
represented by an i128 (i64 under the default implementation), then
None is returned. Read moreSource§fn to_u64(&self) -> Option<u64>
fn to_u64(&self) -> Option<u64>
Converts the value of
self to a u64. If the value cannot be
represented by a u64, then None is returned.Source§fn to_u128(&self) -> Option<u128>
fn to_u128(&self) -> Option<u128>
Converts the value of
self to a u128. If the value cannot be
represented by a u128 (u64 under the default implementation), then
None is returned. Read moreSource§fn to_f64(&self) -> Option<f64>
fn to_f64(&self) -> Option<f64>
Converts the value of
self to an f64. Overflows may map to positive
or negative inifinity, otherwise None is returned if the value cannot
be represented by an f64. Read moreSource§fn to_isize(&self) -> Option<isize>
fn to_isize(&self) -> Option<isize>
Converts the value of
self to an isize. If the value cannot be
represented by an isize, then None is returned.Source§fn to_i8(&self) -> Option<i8>
fn to_i8(&self) -> Option<i8>
Converts the value of
self to an i8. If the value cannot be
represented by an i8, then None is returned.Source§fn to_i16(&self) -> Option<i16>
fn to_i16(&self) -> Option<i16>
Converts the value of
self to an i16. If the value cannot be
represented by an i16, then None is returned.Source§fn to_i32(&self) -> Option<i32>
fn to_i32(&self) -> Option<i32>
Converts the value of
self to an i32. If the value cannot be
represented by an i32, then None is returned.Source§fn to_usize(&self) -> Option<usize>
fn to_usize(&self) -> Option<usize>
Converts the value of
self to a usize. If the value cannot be
represented by a usize, then None is returned.Source§fn to_u8(&self) -> Option<u8>
fn to_u8(&self) -> Option<u8>
Converts the value of
self to a u8. If the value cannot be
represented by a u8, then None is returned.Source§fn to_u16(&self) -> Option<u16>
fn to_u16(&self) -> Option<u16>
Converts the value of
self to a u16. If the value cannot be
represented by a u16, then None is returned.impl<T: Copy> Copy for Ratio<T>
impl<T: Clone + Integer> Eq for Ratio<T>
Auto Trait Implementations§
impl<T> Freeze for Ratio<T>where
T: Freeze,
impl<T> RefUnwindSafe for Ratio<T>where
T: RefUnwindSafe,
impl<T> Send for Ratio<T>where
T: Send,
impl<T> Sync for Ratio<T>where
T: Sync,
impl<T> Unpin for Ratio<T>where
T: Unpin,
impl<T> UnwindSafe for Ratio<T>where
T: UnwindSafe,
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