pub trait BitIndex: BitSize + BitMask {
fn bit(&self, index: usize) -> bool;
fn bits<Idx: RangeBounds<usize>>(&self, index: Idx) -> Self;
}
Expand description
Provides bit indexing operations.
This trait defines functions for accessing single bits to determine whether they are set and for accessing ranges of bits to extract the value they contain.
Examples
use quark::BitIndex;
let value: u32 = 0xe01a3497;
let s = value.bit(20);
assert!(s);
let rd = value.bits(16..20);
assert_eq!(rd, 10);
let rn = value.bits(12..16);
assert_eq!(rn, 3);
let rs = value.bits(8..12);
assert_eq!(rs, 4);
let rm = value.bits(0..4);
assert_eq!(rm, 7);
Required Methods
sourcefn bits<Idx: RangeBounds<usize>>(&self, index: Idx) -> Self
fn bits<Idx: RangeBounds<usize>>(&self, index: Idx) -> Self
Returns the bits contained in the specified bit range.