From d84afb8cff8e1c363b5976e4938433a7f0856fd7 Mon Sep 17 00:00:00 2001 From: Yotoko <44945530+vhgcuong@users.noreply.github.com> Date: Tue, 3 Oct 2023 15:32:02 +0700 Subject: [PATCH] AsRef binary search --- src/binary_search.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/binary_search.rs b/src/binary_search.rs index cca7d7b..66ef639 100644 --- a/src/binary_search.rs +++ b/src/binary_search.rs @@ -1,6 +1,7 @@ use std::cmp::Ordering; -pub fn find(array: &[T], key: T) -> Option { +pub fn find, T: Ord>(array: U, key: T) -> Option { + let array = array.as_ref(); if array.is_empty() { return None; }