Trait bit::BitIndex [] [src]

pub trait BitIndex {
    fn bit_length() -> usize;
    fn bit(&self, pos: usize) -> bool;
    fn bit_range(&self, pos: Range<usize>) -> Self;
    fn set_bit(&mut self, pos: usize, val: bool) -> &mut Self;
    fn set_bit_range(&mut self, pos: Range<usize>, val: Self) -> &mut Self;
}

A trait which provides methods for manipulating bits or bit ranges.

Required Methods

Length of the implementor type in bits.

Obtains the value of the bit at the given position, being 0 the least significant bit.

Panics

This method will panic if the index is out of bounds, e.g: pos >= Self::bit_length().

Obtains the value of the bits inside the given range, being 0 the least significant bit.

Panics

This method will panic if:

  • Range start is equal or higher than end
  • Range end is out of bounds, e.g: pos.end > Self::bit_length()

Sets the value of the bit at the given position, being 0 the least significant bit.

Panics

This method will panic if the index is out of bounds, e.g: pos >= Self::bit_length().

Sets the value of the bits inside the given range, being 0 the least significant bit.

Panics

This method will panic if:

  • Range start is equal or higher than end
  • Range end is out of bounds, e.g: pos.end > Self::bit_length()
  • Value doesn't fit in the given range

Implementors