Trait bitvec::Bits

source ·
pub trait Bits: Sealed + Binary + BitAnd<Self, Output = Self> + BitAndAssign<Self> + BitOrAssign<Self> + Copy + Debug + Default + Display + Eq + From<u8> + LowerHex + Not<Output = Self> + Shl<u8, Output = Self> + ShlAssign<u8> + Shr<u8, Output = Self> + ShrAssign<u8> + Sized + UpperHex {
    const BITS: u8;
    const WIDTH: u8 = _;
    const MASK: u8 = _;
    const MAX_ELT: usize = _;

    fn ones(&self) -> u32;
    fn zeros(&self) -> u32;

    fn set(&mut self, place: u8, value: bool) { ... }
    fn get(&self, place: u8) -> bool { ... }
    fn split(cursor: usize) -> (usize, u8) { ... }
    fn join(elt: usize, bit: u8) -> usize { ... }
}
Expand description

A trait for types that can be used as direct storage of bits.

This trait must only be implemented on unsigned integer primitives.

The dependency on Sealed, a crate-private trait, ensures that this trait can only ever be implemented locally, and no downstream crates are able to implement it on new types.

Required Associated Constants

The number of bits required to index the type. This is always log2 of the type width.

Incidentally, this can be computed as size_of().trailing_zeroes() once that becomes a valid constexpr.

Provided Associated Constants

The width in bits of this type.

The bitmask to turn an arbitrary usize into the bit index. Bit indices are always stored in the lowest bits of an index value.

The maximum number of this type that can be held in a BitVec.

Required Methods

Counts how many bits are set.

Counts how many bits are unset.

Provided Methods

Set a specific bit in an element to a given value.

Get a specific bit in an element.

Splits a usize cursor into an (element, bit) tuple.

The bit component is semantic count, not bit index.

Joins a usize element cursor and u8 bit cursor into a single usize cursor.

Implementations on Foreign Types

Implementors