pub trait BitSearch {
// Required method
fn find_first_set(&self, lower_bound: usize) -> Option<usize>;
// Provided method
fn find_set_in_range<R>(&self, range: R) -> Option<usize>
where R: RangeBounds<usize> { ... }
}Expand description
Search for set its.
Required Methods§
Sourcefn find_first_set(&self, lower_bound: usize) -> Option<usize>
fn find_first_set(&self, lower_bound: usize) -> Option<usize>
Searches for first bit set starting with lower_bound.
Returns index of first bit set.
§Example
fn validate<S: BitSearch + BitSetLimit + BitTest>(set: &S, lower_bound: usize) {
match set.find_first_set(lower_bound) {
None => assert!((lower_bound..=S::MAX_SET_INDEX).all(|idx| !set.test(idx))),
Some(idx) => {
assert!(idx <= S::MAX_SET_INDEX);
assert!((lower_bound..idx).all(|idx| !set.test(idx)));
assert!(set.test(idx));
}
}
}Provided Methods§
Sourcefn find_set_in_range<R>(&self, range: R) -> Option<usize>where
R: RangeBounds<usize>,
fn find_set_in_range<R>(&self, range: R) -> Option<usize>where
R: RangeBounds<usize>,
Searches for bit set specified range. Returns index of bit set.
§Example
fn validate<S: BitSearch + BitTest>(set: &S, mut range: Range<usize>) {
match set.find_set_in_range(range.clone()) {
None => assert!(range.all(|idx| !set.test(idx))),
Some(idx) => {
assert!(idx < range.end);
assert!((range.start..idx).all(|idx| !set.test(idx)));
assert!(set.test(idx));
}
}
}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.