pub struct Rational { /* private fields */ }Expand description
A normalized signed rational number with a positive denominator.
Implementations§
Source§impl Rational
impl Rational
pub fn new(numerator: i64, denominator: i64) -> Result<Self>
pub const fn numerator(self) -> i64
pub const fn denominator(self) -> i64
pub const fn is_positive(self) -> bool
pub fn checked_add(self, other: Self) -> Result<Self>
pub fn checked_sub(self, other: Self) -> Result<Self>
pub fn checked_mul(self, other: Self) -> Result<Self>
pub fn checked_div(self, other: Self) -> Result<Self>
Trait Implementations§
impl Copy for Rational
impl Eq for Rational
Source§impl Ord for Rational
impl Ord for Rational
1.21.0 (const: unstable) · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Compares and returns the maximum of two values. Read more
1.21.0 (const: unstable) · Source§fn min(self, other: Self) -> Selfwhere
Self: Sized,
fn min(self, other: Self) -> Selfwhere
Self: Sized,
Compares and returns the minimum of two values. Read more
Source§impl PartialOrd for Rational
impl PartialOrd 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 UnsafeUnpin 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