pub trait BitBlock:
ShlAssign<u8>
+ Shr
+ BitOrAssign
+ Copy {
// Required methods
fn zero() -> Self;
fn zero_array<const N: usize>() -> [Self; N];
unsafe fn set_bit_unchecked(&mut self, idx: usize);
fn is_zero(self) -> bool;
fn is_one(self) -> bool;
fn leading_zeros(self) -> u32;
// Provided method
fn set_bit(&mut self, idx: usize) { ... }
}
Expand description
A trait abstracting over types which can be used as a block of bits.
At the moment this is unsigned integer primitive types.
The trait is not sealed, so you may implement it, but it unstable and may change.
Required Methods§
Sourcefn zero_array<const N: usize>() -> [Self; N]
fn zero_array<const N: usize>() -> [Self; N]
An array of zero values for this type
Sourceunsafe fn set_bit_unchecked(&mut self, idx: usize)
unsafe fn set_bit_unchecked(&mut self, idx: usize)
Set the single bit at idx
places from the left to 1.
§Safety
The caller guarantees that idx
is less than the number of bits in the type.
Sourcefn leading_zeros(self) -> u32
fn leading_zeros(self) -> u32
The number of leading zeros in the bit-representation.
Provided Methods§
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.