pub fn binary_search<T: Ord>(data: &[T], x: &T) -> Option<usize>Expand description
Returns the index of the value in a sorted slice that equals x,
or None if not found.
ยงExample
use d3rs::array::binary_search;
let data = vec![1, 2, 3, 5, 8, 13];
assert_eq!(binary_search(&data, &5), Some(3));
assert_eq!(binary_search(&data, &4), None);