Struct typerat::Q

source ·
pub struct Q<N, D = P1>(/* private fields */)
where
    N: Numerator<D>,
    D: Denominator;
Expand description

Q<N, D> represents a type-level rational number with numerator N and denominator D.

Implementations§

source§

impl<N, D> Q<N, D>
where N: Numerator<D>, D: Denominator,

source

pub const fn new() -> Self

Constructs a new instance of this type-level rational number.

Trait Implementations§

source§

impl<Nl, Dl, Nr, Dr, No, Do> Add<Q<Nr, Dr>> for Q<Nl, Dl>
where Self: PrivateAddHelper<Q<Nr, Dr>, Output = Q<No, Do>>, Nl: Numerator<Dl>, Dl: Denominator, Nr: Numerator<Dr>, Dr: Denominator, No: Numerator<Do>, Do: Denominator,

§

type Output = Q<No, Do>

The resulting type after applying the + operator.
source§

fn add(self, rhs: Q<Nr, Dr>) -> Self::Output

Performs the + operation. Read more
source§

impl<N, D> Binary for Q<N, D>
where Self: PrivateFmtHelper, N: Numerator<D>, D: Denominator,

source§

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

Formats the value using the given formatter.
source§

impl<N, D> Clone for Q<N, D>
where N: Numerator<D>, D: Denominator,

source§

fn clone(&self) -> Self

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl<Nl, Dl, Nr, Dr> Cmp<Q<Nr, Dr>> for Q<Nl, Dl>
where Self: PrivateCmpHelper<Q<Nr, Dr>>, Nl: Numerator<Dl>, Dl: Denominator, Nr: Numerator<Dr>, Dr: Denominator,

§

type Output = <Q<Nl, Dl> as PrivateCmpHelper<Q<Nr, Dr>>>::Output

The resulting type after type-level comparison.
source§

fn cmp(&self, other: &Rhs) -> Self::Output

Performs comparison.
source§

impl<N, D> Debug for Q<N, D>
where N: Numerator<D> + Debug, D: Denominator + Debug,

source§

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

Formats the value using the given formatter. Read more
source§

impl<N, D> Default for Q<N, D>
where N: Numerator<D>, D: Denominator,

source§

fn default() -> Self

Returns the “default value” for a type. Read more
source§

impl<N, D> Display for Q<N, D>
where Self: PrivateFmtHelper, N: Numerator<D>, D: Denominator,

source§

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

Formats the value using the given formatter. Read more
source§

impl<Nl, Dl, Nr, Dr, No, Do> Div<Q<Nr, Dr>> for Q<Nl, Dl>
where Self: Mul<<Q<Nr, Dr> as Recip>::Output, Output = Q<No, Do>>, Q<Nr, Dr>: Recip, Nl: Numerator<Dl>, Dl: Denominator, Nr: Numerator<Dr>, Dr: Denominator, No: Numerator<Do>, Do: Denominator,

§

type Output = Q<No, Do>

The resulting type after applying the / operator.
source§

fn div(self, rhs: Q<Nr, Dr>) -> Self::Output

Performs the / operation. Read more
source§

impl<N, D> LowerHex for Q<N, D>
where Self: PrivateFmtHelper, N: Numerator<D>, D: Denominator,

source§

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

Formats the value using the given formatter.
source§

impl<Nl, Dl, Nr, Dr, No, Do> Mul<Q<Nr, Dr>> for Q<Nl, Dl>
where Self: PrivateMulHelper<Q<Nr, Dr>, Output = Q<No, Do>>, Nl: Numerator<Dl>, Dl: Denominator, Nr: Numerator<Dr>, Dr: Denominator, No: Numerator<Do>, Do: Denominator,

§

type Output = Q<No, Do>

The resulting type after applying the * operator.
source§

fn mul(self, rhs: Q<Nr, Dr>) -> Self::Output

Performs the * operation. Read more
source§

impl<N, D, No> Neg for Q<N, D>
where N: Numerator<D> + Neg<Output = No>, D: Denominator, No: Numerator<D>,

§

type Output = Q<No, D>

The resulting type after applying the - operator.
source§

fn neg(self) -> Self::Output

Performs the unary - operation. Read more
source§

impl<N, D> Octal for Q<N, D>
where Self: PrivateFmtHelper, N: Numerator<D>, D: Denominator,

source§

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

Formats the value using the given formatter.
source§

impl<Nl, Dl, Nr, Dr> PartialEq<Q<Nr, Dr>> for Q<Nl, Dl>
where Self: Cmp<Q<Nr, Dr>>, Nl: Numerator<Dl>, Dl: Denominator, Nr: Numerator<Dr>, Dr: Denominator,

source§

fn eq(&self, other: &Q<Nr, Dr>) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl<Nl, Dl, Nr, Dr> PartialOrd<Q<Nr, Dr>> for Q<Nl, Dl>
where Self: Cmp<Q<Nr, Dr>>, Nl: Numerator<Dl>, Dl: Denominator, Nr: Numerator<Dr>, Dr: Denominator,

source§

fn partial_cmp(&self, other: &Q<Nr, Dr>) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · source§

fn lt(&self, other: &Rhs) -> bool

This method tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · source§

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 more
1.0.0 · source§

fn gt(&self, other: &Rhs) -> bool

This method tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · source§

fn ge(&self, other: &Rhs) -> bool

This method tests greater than or equal to (for self and other) and is used by the >= operator. Read more
source§

impl<N, D> Rational for Q<N, D>
where Self: Sealed, N: Numerator<D>, D: Denominator,

source§

const F64: f64 = <Self as PrivateF64Helper>::F64

Approximate 64-bit floating point number of this rational number. Read more
source§

impl<Un, Ud> Recip for Q<NInt<Un>, PInt<Ud>>

§

type Output = Q<NInt<Ud>, PInt<Un>>

The resulting type after applying the reciprocal operation.
source§

impl<Un, Ud> Recip for Q<PInt<Un>, PInt<Ud>>

§

type Output = Q<PInt<Ud>, PInt<Un>>

The resulting type after applying the reciprocal operation.
source§

impl<Nl, Dl, Nr, Dr, No, Do> Rem<Q<Nr, Dr>> for Q<Nl, Dl>
where Self: PrivateRemHelper<Q<Nr, Dr>, Output = Q<No, Do>>, Q<Nr, Dr>: NonZero, Nl: Numerator<Dl>, Dl: Denominator, Nr: Numerator<Dr>, Dr: Denominator, No: Numerator<Do>, Do: Denominator,

§

type Output = Q<No, Do>

The resulting type after applying the % operator.
source§

fn rem(self, rhs: Q<Nr, Dr>) -> Self::Output

Performs the % operation. Read more
source§

impl<Nl, Dl, Nr, Dr, No, Do> Sub<Q<Nr, Dr>> for Q<Nl, Dl>
where Self: Add<<Q<Nr, Dr> as Neg>::Output, Output = Q<No, Do>>, Q<Nr, Dr>: Neg, Nl: Numerator<Dl>, Dl: Denominator, Nr: Numerator<Dr>, Dr: Denominator, No: Numerator<Do>, Do: Denominator,

§

type Output = Q<No, Do>

The resulting type after applying the - operator.
source§

fn sub(self, rhs: Q<Nr, Dr>) -> Self::Output

Performs the - operation. Read more
source§

impl<N, D> UpperHex for Q<N, D>
where Self: PrivateFmtHelper, N: Numerator<D>, D: Denominator,

source§

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

Formats the value using the given formatter.
source§

impl<N, D> Copy for Q<N, D>
where N: Numerator<D>, D: Denominator,

source§

impl<N, D> NonNegative for Q<N, D>
where N: Numerator<D> + NonNegative, D: Denominator,

source§

impl<N, D> NonZero for Q<N, D>
where N: Numerator<D> + NonZero, D: Denominator,

source§

impl<N> NotOne for Q<N>
where N: Numerator + NotOne,

source§

impl<N, D> NotOne for Q<N, D>
where N: Numerator<D>, D: Denominator + NotOne,

Auto Trait Implementations§

§

impl<N, D> RefUnwindSafe for Q<N, D>

§

impl<N, D> Send for Q<N, D>
where D: Send, N: Send,

§

impl<N, D> Sync for Q<N, D>
where D: Sync, N: Sync,

§

impl<N, D> Unpin for Q<N, D>
where D: Unpin, N: Unpin,

§

impl<N, D> UnwindSafe for Q<N, D>
where D: UnwindSafe, N: UnwindSafe,

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

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

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

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

source§

impl<T> Same for T

§

type Output = T

Should always be Self
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

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

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

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

Performs the conversion.