Skip to content

Commit

Permalink
AsRef binary search
Browse files Browse the repository at this point in the history
  • Loading branch information
vhgcuong committed Oct 3, 2023
1 parent de2b4c4 commit d84afb8
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/binary_search.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
use std::cmp::Ordering;

pub fn find<T: Ord>(array: &[T], key: T) -> Option<usize> {
pub fn find<U: AsRef<[T]>, T: Ord>(array: U, key: T) -> Option<usize> {
let array = array.as_ref();
if array.is_empty() {
return None;
}
Expand Down

0 comments on commit d84afb8

Please sign in to comment.