pub trait BitsExt {
// Required methods
fn extract_bit(self, index: usize) -> bool;
fn extract_bits(self, range: Range<usize>) -> Self;
fn replace_bit(self, index: usize, value: bool) -> Self;
fn replace_bits(self, range: Range<usize>, value: Self) -> Self;
}
Expand description
Provides a simpler interface to extract from a given value and replace bits in a given value than manipulating the value directly using bit shifting and masking.
Required Methods§
Sourcefn extract_bit(self, index: usize) -> bool
fn extract_bit(self, index: usize) -> bool
Extracts a single bit from the integer at the given index. Returns true
if the bit is
set, false
otherwise.
Sourcefn extract_bits(self, range: Range<usize>) -> Self
fn extract_bits(self, range: Range<usize>) -> Self
Extracts the given range of bits from the integer.
Sourcefn replace_bit(self, index: usize, value: bool) -> Self
fn replace_bit(self, index: usize, value: bool) -> Self
Replaces a single bit in the integer at the given index.
Sourcefn replace_bits(self, range: Range<usize>, value: Self) -> Self
fn replace_bits(self, range: Range<usize>, value: Self) -> Self
Replaces the given range of bits in the integer with the given value.
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.