pub trait Bits {
type Store: BitOps + Default + Copy + PartialEq + Debug;
const VALUE: usize;
// Provided methods
fn corrected_first_false_index(store: &Self::Store) -> Option<usize> { ... }
fn corrected_last_false_index(store: &Self::Store) -> Option<usize> { ... }
fn corrected_next_false_index(
store: &Self::Store,
index: usize,
) -> Option<usize> { ... }
}
Expand description
A type level number signifying the number of bits in a bitmap.
This trait is implemented for type level numbers from U1
to U1024
.
§Examples
assert_eq!(
std::mem::size_of::<<BitsImpl<10> as Bits>::Store>(),
std::mem::size_of::<u16>()
);
Required Associated Types§
Required Associated Constants§
Provided Methods§
sourcefn corrected_first_false_index(store: &Self::Store) -> Option<usize>
fn corrected_first_false_index(store: &Self::Store) -> Option<usize>
The underlying data type might have some trailing bits, which would result in an invalid value being returned.
Thankfully, this only happens for ‘false_index’-functions (bits higher than VALUE - 1 cannot be set), and even then only for functions that might seek in that area: that is all forward seeking functions, and the one seeking backwards from the end (last_false_index). prev_false_index is not affected, because the supplied index must be valid, and any index lower than that is also valid.
sourcefn corrected_last_false_index(store: &Self::Store) -> Option<usize>
fn corrected_last_false_index(store: &Self::Store) -> Option<usize>
The underlying data type might have some trailing bits, which would result in an invalid result, so we check against that here.