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§
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
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.