pub struct Ratio { /* private fields */ }Expand description
An exact ratio of two integers, reduced to lowest terms on construction.
Unlike a float, a Ratio compares and hashes exactly: two ratios built
from different numerator/denominator pairs are equal whenever they denote
the same fraction (Ratio::new(1, 2) == Ratio::new(2, 4)), with no
rounding or bit-pattern comparison involved. This makes it a good fit for
comptime kernel parameters that are always derived from integers (tensor
shapes, tile sizes, and the like).
For a value that is not exactly the ratio of two integers, use
ComptimeFloat instead.
Implementations§
Trait Implementations§
impl Copy for Ratio
impl Eq for Ratio
impl StructuralPartialEq for Ratio
Auto Trait Implementations§
impl Freeze for Ratio
impl RefUnwindSafe for Ratio
impl Send for Ratio
impl Sync for Ratio
impl Unpin for Ratio
impl UnsafeUnpin for Ratio
impl UnwindSafe for Ratio
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key and return true if they are equal.