bit_vec

Trait BitBlock

Source
pub trait BitBlock:
    Copy
    + Add<Self, Output = Self>
    + Sub<Self, Output = Self>
    + Shl<usize, Output = Self>
    + Shr<usize, Output = Self>
    + Not<Output = Self>
    + BitAnd<Self, Output = Self>
    + BitOr<Self, Output = Self>
    + BitXor<Self, Output = Self>
    + Rem<Self, Output = Self>
    + Eq
    + Ord
    + Hash {
    // Required methods
    fn bits() -> usize;
    fn from_byte(byte: u8) -> Self;
    fn count_ones(self) -> usize;
    fn zero() -> Self;
    fn one() -> Self;

    // Provided method
    fn bytes() -> usize { ... }
}
Expand description

Abstracts over a pile of bits (basically unsigned primitives)

Required Methods§

Source

fn bits() -> usize

How many bits it has

Source

fn from_byte(byte: u8) -> Self

Convert a byte into this type (lowest-order bits set)

Source

fn count_ones(self) -> usize

Count the number of 1’s in the bitwise repr

Source

fn zero() -> Self

Get 0

Source

fn one() -> Self

Get 1

Provided Methods§

Source

fn bytes() -> usize

How many bytes it has

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.

Implementations on Foreign Types§

Source§

impl BitBlock for u8

Source§

fn bits() -> usize

Source§

fn from_byte(byte: u8) -> Self

Source§

fn count_ones(self) -> usize

Source§

fn one() -> Self

Source§

fn zero() -> Self

Source§

impl BitBlock for u16

Source§

fn bits() -> usize

Source§

fn from_byte(byte: u8) -> Self

Source§

fn count_ones(self) -> usize

Source§

fn one() -> Self

Source§

fn zero() -> Self

Source§

impl BitBlock for u32

Source§

fn bits() -> usize

Source§

fn from_byte(byte: u8) -> Self

Source§

fn count_ones(self) -> usize

Source§

fn one() -> Self

Source§

fn zero() -> Self

Source§

impl BitBlock for u64

Source§

fn bits() -> usize

Source§

fn from_byte(byte: u8) -> Self

Source§

fn count_ones(self) -> usize

Source§

fn one() -> Self

Source§

fn zero() -> Self

Source§

impl BitBlock for usize

Source§

fn bits() -> usize

Source§

fn from_byte(byte: u8) -> Self

Source§

fn count_ones(self) -> usize

Source§

fn one() -> Self

Source§

fn zero() -> Self

Implementors§