quickbits

Trait BitManip

Source
pub trait BitManip: BitManipInternal {
Show 24 methods // Provided methods fn bit(&self, bit_index: Self) -> Self { ... } fn bit_bool(&self, bit_index: Self) -> bool { ... } fn b(&self, range: impl AsRange<Self>) -> Self { ... } fn bits(&self, range: impl AsRange<Self>) -> Self { ... } fn set_bit(&self, bit_index: Self) -> Self { ... } fn set_bits(&self, range: impl AsRange<Self>) -> Self { ... } fn set_bit_assign(&mut self, bit_index: Self) { ... } fn set_bits_assign(&mut self, range: impl AsRange<Self>) { ... } fn clear_bit(&self, bit_index: Self) -> Self { ... } fn clear_bits(&self, range: impl AsRange<Self>) -> Self { ... } fn clear_bit_assign(&mut self, bit_index: Self) { ... } fn clear_bits_assign(&mut self, range: impl AsRange<Self>) { ... } fn toggle_bit(&self, bit_index: Self) -> Self { ... } fn toggle_bits(&self, range: impl AsRange<Self>) -> Self { ... } fn toggle_bit_assign(&mut self, bit_index: Self) { ... } fn toggle_bits_assign(&mut self, range: impl AsRange<Self>) { ... } fn replace_bit(&self, bit_index: Self, value: impl Into<bool>) -> Self { ... } fn replace_bits(&self, _range: impl AsRange<Self>, _value: Self) -> Self { ... } fn replace_bit_assign(&mut self, bit_index: Self, value: impl Into<bool>) { ... } fn replace_bits_assign(&mut self, range: impl AsRange<Self>, value: Self) { ... } fn bitmask(range: impl AsRange<Self>) -> Self { ... } fn permute(&self, ranges: &[impl AsRange<Self>]) -> Self { ... } fn sign_extend_from_bit(&self, bit_index: Self) -> Self { ... } fn sign_extend_from_size(&self, size: Self) -> Self { ... }
}
Expand description

TODO document

Provided Methods§

Source

fn bit(&self, bit_index: Self) -> Self

Extracts the bit at the given index from the integer

§Examples
use quickbits::BitManip;
assert_eq!(0b1010_1010.bit(5), 1);
assert_eq!(0b1010_1010.bit(6), 0);
Source

fn bit_bool(&self, bit_index: Self) -> bool

Like bit(), but returns a bool instead of an integer

§Examples
use quickbits::BitManip;
assert_eq!(0b1010_1010.bit_bool(5), true);
assert_eq!(0b1010_1010.bit_bool(6), false);
Source

fn b(&self, range: impl AsRange<Self>) -> Self

Convenient alias for bits()

§Examples
use quickbits::BitManip;
assert_eq!(0b1010_1010.b(3..=0), 0b1010_1010.bits(3..=0));
assert_eq!(0b1010_1010.b(7), 0b1010_1010.bits(7));
Source

fn bits(&self, range: impl AsRange<Self>) -> Self

Extracts the bits in the given range (or at the given index) from the integer

§Examples
use quickbits::BitManip;
assert_eq!(0b1010_1010.bits(3..=0), 0b1010);
assert_eq!(0b1010_1010.bits(7), 1);
Source

fn set_bit(&self, bit_index: Self) -> Self

TODO document

Source

fn set_bits(&self, range: impl AsRange<Self>) -> Self

TODO document

Source

fn set_bit_assign(&mut self, bit_index: Self)

TODO document

Source

fn set_bits_assign(&mut self, range: impl AsRange<Self>)

TODO document

Source

fn clear_bit(&self, bit_index: Self) -> Self

TODO document

Source

fn clear_bits(&self, range: impl AsRange<Self>) -> Self

TODO document

Source

fn clear_bit_assign(&mut self, bit_index: Self)

TODO document

Source

fn clear_bits_assign(&mut self, range: impl AsRange<Self>)

TODO document

Source

fn toggle_bit(&self, bit_index: Self) -> Self

TODO document

Source

fn toggle_bits(&self, range: impl AsRange<Self>) -> Self

TODO document

Source

fn toggle_bit_assign(&mut self, bit_index: Self)

TODO document

Source

fn toggle_bits_assign(&mut self, range: impl AsRange<Self>)

TODO document

Source

fn replace_bit(&self, bit_index: Self, value: impl Into<bool>) -> Self

TODO document

Source

fn replace_bits(&self, _range: impl AsRange<Self>, _value: Self) -> Self

TODO document

Source

fn replace_bit_assign(&mut self, bit_index: Self, value: impl Into<bool>)

TODO document

Source

fn replace_bits_assign(&mut self, range: impl AsRange<Self>, value: Self)

TODO document

Source

fn bitmask(range: impl AsRange<Self>) -> Self

TODO document

Source

fn permute(&self, ranges: &[impl AsRange<Self>]) -> Self

TODO document

Source

fn sign_extend_from_bit(&self, bit_index: Self) -> Self

TODO document

Source

fn sign_extend_from_size(&self, size: Self) -> Self

TODO document

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.

Implementors§

Source§

impl<T> BitManip for T
where T: BitManipInternal,