Trait BitField

Source
pub trait BitField:
    BitAnd<Output = Self>
    + BitOr<Output = Self>
    + Not<Output = Self>
    + Sized
    + Copy {
    // Required methods
    fn empty() -> Self;
    fn set_bit(&mut self, n: usize, state: bool);
    fn get_bit(&self, n: usize) -> bool;
    fn n_bits() -> usize;
}
Expand description

A trait for a type that can work as a bitfield.

Required Methods§

Source

fn empty() -> Self

Creates a bitfield with no bits set

Source

fn set_bit(&mut self, n: usize, state: bool)

Sets a bit. Assumes that n is less than n_bits

Source

fn get_bit(&self, n: usize) -> bool

Gets a bit. Assumes that n is less than n_bits

Source

fn n_bits() -> usize

Returns the number of bits.

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 BitField for u8

Source§

fn empty() -> Self

Source§

fn set_bit(&mut self, n: usize, state: bool)

Source§

fn get_bit(&self, n: usize) -> bool

Source§

fn n_bits() -> usize

Source§

impl BitField for u16

Source§

fn empty() -> Self

Source§

fn set_bit(&mut self, n: usize, state: bool)

Source§

fn get_bit(&self, n: usize) -> bool

Source§

fn n_bits() -> usize

Source§

impl BitField for u32

Source§

fn empty() -> Self

Source§

fn set_bit(&mut self, n: usize, state: bool)

Source§

fn get_bit(&self, n: usize) -> bool

Source§

fn n_bits() -> usize

Source§

impl BitField for u64

Source§

fn empty() -> Self

Source§

fn set_bit(&mut self, n: usize, state: bool)

Source§

fn get_bit(&self, n: usize) -> bool

Source§

fn n_bits() -> usize

Source§

impl BitField for u128

Source§

fn empty() -> Self

Source§

fn set_bit(&mut self, n: usize, state: bool)

Source§

fn get_bit(&self, n: usize) -> bool

Source§

fn n_bits() -> usize

Implementors§