Skip to main content

ConstPrimInt

Trait ConstPrimInt 

Source
pub trait ConstPrimInt:
    Add<Output = Self>
    + Sub<Output = Self>
    + Mul<Output = Self>
    + Div<Output = Self>
    + BitAnd<Output = Self>
    + BitOr<Output = Self>
    + BitXor<Output = Self>
    + Not<Output = Self>
    + Shl<usize, Output = Self>
    + Shr<usize, Output = Self>
    + AddAssign
    + SubAssign
    + BitAndAssign
    + BitOrAssign
    + BitXorAssign
    + ShlAssign<usize>
    + ShrAssign<usize>
    + PartialEq
    + Eq
    + PartialOrd
    + Ord
    + From<u8>
    + Default
    + ConstOne
    + ConstZero
    + ConstBounded
    + Sized
    + Copy {
Show 19 methods // Required methods fn swap_bytes(self) -> Self; fn leading_zeros(self) -> u32; fn trailing_zeros(self) -> u32; fn count_zeros(self) -> u32; fn count_ones(self) -> u32; fn rotate_left(self, n: u32) -> Self; fn rotate_right(self, n: u32) -> Self; fn unsigned_shl(self, n: u32) -> Self; fn unsigned_shr(self, n: u32) -> Self; fn reverse_bits(self) -> Self; fn from_be(x: Self) -> Self; fn from_le(x: Self) -> Self; fn to_be(self) -> Self; fn to_le(self) -> Self; fn pow(self, exp: u32) -> Self; // Provided methods fn leading_ones(self) -> u32 { ... } fn trailing_ones(self) -> u32 { ... } fn signed_shl(self, n: u32) -> Self { ... } fn signed_shr(self, n: u32) -> Self { ... }
}
Expand description

Base arithmetic traits for constant primitive integers.

§Implementor requirements for default methods

The default implementations of leading_ones and trailing_ones rely on !self (bitwise NOT) producing a value with the same fixed bit-width, and leading_zeros/trailing_zeros counting from the MSB/LSB of that full representation. This is correct for all fixed-width unsigned integers (primitives and FixedUInt), but implementors of custom types should verify these assumptions hold or override the defaults.

Required Methods§

Source

fn swap_bytes(self) -> Self

Source

fn leading_zeros(self) -> u32

Source

fn trailing_zeros(self) -> u32

Source

fn count_zeros(self) -> u32

Source

fn count_ones(self) -> u32

Source

fn rotate_left(self, n: u32) -> Self

Source

fn rotate_right(self, n: u32) -> Self

Source

fn unsigned_shl(self, n: u32) -> Self

Source

fn unsigned_shr(self, n: u32) -> Self

Source

fn reverse_bits(self) -> Self

Source

fn from_be(x: Self) -> Self

Source

fn from_le(x: Self) -> Self

Source

fn to_be(self) -> Self

Source

fn to_le(self) -> Self

Source

fn pow(self, exp: u32) -> Self

Provided Methods§

Source

fn leading_ones(self) -> u32

Source

fn trailing_ones(self) -> u32

Source

fn signed_shl(self, n: u32) -> Self

Source

fn signed_shr(self, n: u32) -> Self

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 ConstPrimInt for u8

Source§

fn leading_zeros(self) -> u32

Source§

fn trailing_zeros(self) -> u32

Source§

fn count_zeros(self) -> u32

Source§

fn count_ones(self) -> u32

Source§

fn swap_bytes(self) -> Self

Source§

fn rotate_left(self, n: u32) -> Self

Source§

fn rotate_right(self, n: u32) -> Self

Source§

fn unsigned_shl(self, n: u32) -> Self

Source§

fn unsigned_shr(self, n: u32) -> Self

Source§

fn reverse_bits(self) -> Self

Source§

fn from_be(x: Self) -> Self

Source§

fn from_le(x: Self) -> Self

Source§

fn to_be(self) -> Self

Source§

fn to_le(self) -> Self

Source§

fn pow(self, exp: u32) -> Self

Source§

impl ConstPrimInt for u16

Source§

fn leading_zeros(self) -> u32

Source§

fn trailing_zeros(self) -> u32

Source§

fn count_zeros(self) -> u32

Source§

fn count_ones(self) -> u32

Source§

fn swap_bytes(self) -> Self

Source§

fn rotate_left(self, n: u32) -> Self

Source§

fn rotate_right(self, n: u32) -> Self

Source§

fn unsigned_shl(self, n: u32) -> Self

Source§

fn unsigned_shr(self, n: u32) -> Self

Source§

fn reverse_bits(self) -> Self

Source§

fn from_be(x: Self) -> Self

Source§

fn from_le(x: Self) -> Self

Source§

fn to_be(self) -> Self

Source§

fn to_le(self) -> Self

Source§

fn pow(self, exp: u32) -> Self

Source§

impl ConstPrimInt for u32

Source§

fn leading_zeros(self) -> u32

Source§

fn trailing_zeros(self) -> u32

Source§

fn count_zeros(self) -> u32

Source§

fn count_ones(self) -> u32

Source§

fn swap_bytes(self) -> Self

Source§

fn rotate_left(self, n: u32) -> Self

Source§

fn rotate_right(self, n: u32) -> Self

Source§

fn unsigned_shl(self, n: u32) -> Self

Source§

fn unsigned_shr(self, n: u32) -> Self

Source§

fn reverse_bits(self) -> Self

Source§

fn from_be(x: Self) -> Self

Source§

fn from_le(x: Self) -> Self

Source§

fn to_be(self) -> Self

Source§

fn to_le(self) -> Self

Source§

fn pow(self, exp: u32) -> Self

Source§

impl ConstPrimInt for u64

Source§

fn leading_zeros(self) -> u32

Source§

fn trailing_zeros(self) -> u32

Source§

fn count_zeros(self) -> u32

Source§

fn count_ones(self) -> u32

Source§

fn swap_bytes(self) -> Self

Source§

fn rotate_left(self, n: u32) -> Self

Source§

fn rotate_right(self, n: u32) -> Self

Source§

fn unsigned_shl(self, n: u32) -> Self

Source§

fn unsigned_shr(self, n: u32) -> Self

Source§

fn reverse_bits(self) -> Self

Source§

fn from_be(x: Self) -> Self

Source§

fn from_le(x: Self) -> Self

Source§

fn to_be(self) -> Self

Source§

fn to_le(self) -> Self

Source§

fn pow(self, exp: u32) -> Self

Source§

impl ConstPrimInt for u128

Source§

fn leading_zeros(self) -> u32

Source§

fn trailing_zeros(self) -> u32

Source§

fn count_zeros(self) -> u32

Source§

fn count_ones(self) -> u32

Source§

fn swap_bytes(self) -> Self

Source§

fn rotate_left(self, n: u32) -> Self

Source§

fn rotate_right(self, n: u32) -> Self

Source§

fn unsigned_shl(self, n: u32) -> Self

Source§

fn unsigned_shr(self, n: u32) -> Self

Source§

fn reverse_bits(self) -> Self

Source§

fn from_be(x: Self) -> Self

Source§

fn from_le(x: Self) -> Self

Source§

fn to_be(self) -> Self

Source§

fn to_le(self) -> Self

Source§

fn pow(self, exp: u32) -> Self

Implementors§

Source§

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