Trait typerat::Rational

source ·
pub trait Rational: 'static + Default + Copy + Sealed {
    const F64: f64;

    // Required method
    fn borrow<'a>() -> &'a Self;
}
Expand description

Type-level rational numbers.

Required Associated Constants§

source

const F64: f64

Approximate 64-bit floating point number of this rational number.

§Examples
use typerat::*;

assert_eq!(Q::<Z0>::F64, 0_f64);
assert_eq!(Q::<P1>::F64, 1_f64);
assert_eq!(Q::<N1>::F64, -1_f64);
assert_eq!(Q::<N1, P2>::F64, -0.5_f64);
assert_eq!(Q::<P1, P3>::F64, 1_f64 / 3_f64);
assert_eq!(Q::<N5, P3>::F64, -1_f64 - 1_f64 / 1.5_f64);

Required Methods§

source

fn borrow<'a>() -> &'a Self

Borrows an instance of this type-level rational number.

Object Safety§

This trait is not object safe.

Implementors§

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