Skip to main content

ConstMultiple

Trait ConstMultiple 

Source
pub trait ConstMultiple:
    Sized
    + ConstZero
    + Rem<Output = Self>
    + Add<Output = Self>
    + Sub<Output = Self>
    + Eq {
    // Required methods
    fn is_multiple_of(&self, rhs: &Self) -> bool;
    fn next_multiple_of(self, rhs: Self) -> Self;
    fn checked_next_multiple_of(self, rhs: Self) -> Option<Self>;
}
Expand description

Const-compatible multiple-of operations.

§Unsigned types only

This trait is designed for unsigned integer types.

Required Methods§

Source

fn is_multiple_of(&self, rhs: &Self) -> bool

Returns true if self is a multiple of rhs.

Returns false if rhs is zero.

Source

fn next_multiple_of(self, rhs: Self) -> Self

Returns the smallest value greater than or equal to self that is a multiple of rhs.

§Panics

Panics if rhs is zero, or if the result would overflow.

Source

fn checked_next_multiple_of(self, rhs: Self) -> Option<Self>

Returns the smallest value greater than or equal to self that is a multiple of rhs.

Returns None if rhs is zero, or if the result would overflow.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementations on Foreign Types§

Source§

impl ConstMultiple for u8

Source§

fn is_multiple_of(&self, rhs: &Self) -> bool

Source§

fn next_multiple_of(self, rhs: Self) -> Self

Source§

fn checked_next_multiple_of(self, rhs: Self) -> Option<Self>

Source§

impl ConstMultiple for u16

Source§

fn is_multiple_of(&self, rhs: &Self) -> bool

Source§

fn next_multiple_of(self, rhs: Self) -> Self

Source§

fn checked_next_multiple_of(self, rhs: Self) -> Option<Self>

Source§

impl ConstMultiple for u32

Source§

fn is_multiple_of(&self, rhs: &Self) -> bool

Source§

fn next_multiple_of(self, rhs: Self) -> Self

Source§

fn checked_next_multiple_of(self, rhs: Self) -> Option<Self>

Source§

impl ConstMultiple for u64

Source§

fn is_multiple_of(&self, rhs: &Self) -> bool

Source§

fn next_multiple_of(self, rhs: Self) -> Self

Source§

fn checked_next_multiple_of(self, rhs: Self) -> Option<Self>

Source§

impl ConstMultiple for u128

Source§

fn is_multiple_of(&self, rhs: &Self) -> bool

Source§

fn next_multiple_of(self, rhs: Self) -> Self

Source§

fn checked_next_multiple_of(self, rhs: Self) -> Option<Self>

Implementors§

Source§

impl<T: ConstMachineWord + MachineWord, const N: usize> ConstMultiple for FixedUInt<T, N>