Trait bit_vec::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 methods
    fn bytes() -> usize { ... }
    fn count_zeros(self) -> 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

source

fn count_zeros(self) -> usize

Count the number of 0’s in the bitwise repr

Object Safety§

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 count_zeros(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 count_zeros(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 count_zeros(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 count_zeros(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 count_zeros(self) -> usize

source§

fn one() -> Self

source§

fn zero() -> Self

Implementors§