Struct Rational

struct Rational { ... }

A rational number.

Fields

num: u64

Numerator.

den: u64

Denominator.

Implementations

impl Rational

const fn new(num: u64, den: u64) -> Self

Creates a rational number from the given numerator and denominator.

const fn from_reciprocal(reciprocal: Self) -> Self

Returns a rational number that is the reciprocal of the given one.

fn as_f64(self: Self) -> f64

Returns the rational number as a floating-point number.

impl Clone for Rational

fn clone(self: &Self) -> Rational

impl Copy for Rational

impl Debug for Rational

fn fmt(self: &Self, f: &mut Formatter<'_>) -> Result

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

impl<T> Any for Rational

fn type_id(self: &Self) -> TypeId

impl<T> Borrow for Rational

fn borrow(self: &Self) -> &T

impl<T> BorrowMut for Rational

fn borrow_mut(self: &mut Self) -> &mut T

impl<T> CloneToUninit for Rational

unsafe fn clone_to_uninit(self: &Self, dest: *mut u8)

impl<T> From for Rational

fn from(t: T) -> T

Returns the argument unchanged.

impl<T> ToOwned for Rational

fn to_owned(self: &Self) -> T
fn clone_into(self: &Self, target: &mut T)

impl<T, U> Into for Rational

fn into(self: Self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of [From]<T> for U chooses to do.

impl<T, U> TryFrom for Rational

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

impl<T, U> TryInto for Rational

fn try_into(self: Self) -> Result<U, <U as TryFrom<T>>::Error>