Skip to main content

BitArray

Trait BitArray 

Source
pub trait BitArray {
    // Required methods
    fn bit(&self, idx: usize) -> bool;
    fn bit_slice(&self, start: usize, end: usize) -> Self;
    fn mask(&self, n: usize) -> Self;
    fn trailing_zeros(&self) -> usize;
    fn zero() -> Self;
    fn one() -> Self;
}
Expand description

A trait which allows numbers to act as fixed-size bit arrays

Required Methods§

Source

fn bit(&self, idx: usize) -> bool

Is bit set?

Source

fn bit_slice(&self, start: usize, end: usize) -> Self

Returns an array which is just the bits from start to end

Source

fn mask(&self, n: usize) -> Self

Bitwise and with n ones

Source

fn trailing_zeros(&self) -> usize

Trailing zeros

Source

fn zero() -> Self

Create all-zeros value

Source

fn one() -> Self

Create value representing one

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§