Trait bitvec::Bits[][src]

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 WIDTH: u8;
    const BITS: 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 { ... } }

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.

Associated Constants

WIDTH: u8 = 1 << <Self>::BITS

The width in bits of this type.

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.

MASK: u8 = <Self>::WIDTH - 1

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

MAX_ELT: usize = ::std::usize::MAX >> <Self>::BITS

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

impl Bits for u8
[src]

impl Bits for u16
[src]

impl Bits for u32
[src]

impl Bits for u64
[src]

Implementors