pub trait ExactSearch {
type Item;
// Required methods
fn exact_search(&self, x: &Self::Item) -> Result<usize, usize>
where Self::Item: Ord;
fn exact_search_by<'a, F>(&'a self, f: F) -> Result<usize, usize>
where F: FnMut(&'a Self::Item) -> Ordering;
fn exact_search_by_key<'a, K, F>(
&'a self,
key: &K,
f: F,
) -> Result<usize, usize>
where F: FnMut(&'a Self::Item) -> K,
K: Ord;
}Expand description
Exact search for ordered slices with an early equality exit and branchless search-direction selection.
This combines the useful properties of a conventional early-exit binary search with the conditional selection used by modern standard-library binary search implementations. It returns either a matching index or the position where the value can be inserted while preserving order.
Required Associated Types§
Required Methods§
Sourcefn exact_search(&self, x: &Self::Item) -> Result<usize, usize>
fn exact_search(&self, x: &Self::Item) -> Result<usize, usize>
Searches for x, returning a matching index or its insertion position.
Sourcefn exact_search_by<'a, F>(&'a self, f: F) -> Result<usize, usize>
fn exact_search_by<'a, F>(&'a self, f: F) -> Result<usize, usize>
Searches with a comparator, returning a match or insertion position.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".