From 4ee89363fb6d538e28dd9375e69580d139ddacea Mon Sep 17 00:00:00 2001 From: Ms2ger Date: Fri, 24 Apr 2015 17:44:04 +0200 Subject: [PATCH] Define the binary search methods on [T] rather than &[T]. --- components/util/vec.rs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/components/util/vec.rs b/components/util/vec.rs index cce3e867676..5b26e6334a0 100644 --- a/components/util/vec.rs +++ b/components/util/vec.rs @@ -11,8 +11,8 @@ pub trait Comparator { fn compare(&self, key: &K, value: &T) -> Ordering; } -pub trait BinarySearchMethods<'a, T: Ord + PartialOrd + PartialEq> { - fn binary_search_(&self, key: &T) -> Option<&'a T>; +pub trait BinarySearchMethods { + fn binary_search_(&self, key: &T) -> Option<&T>; fn binary_search_index(&self, key: &T) -> Option; } @@ -20,8 +20,8 @@ pub trait FullBinarySearchMethods { fn binary_search_index_by>(&self, key: &K, cmp: C) -> Option; } -impl<'a, T: Ord + PartialOrd + PartialEq> BinarySearchMethods<'a, T> for &'a [T] { - fn binary_search_(&self, key: &T) -> Option<&'a T> { +impl BinarySearchMethods for [T] { + fn binary_search_(&self, key: &T) -> Option<&T> { self.binary_search_index(key).map(|i| &self[i]) } @@ -30,7 +30,7 @@ impl<'a, T: Ord + PartialOrd + PartialEq> BinarySearchMethods<'a, T> for &'a [T] } } -impl<'a, T> FullBinarySearchMethods for &'a [T] { +impl FullBinarySearchMethods for [T] { fn binary_search_index_by>(&self, key: &K, cmp: C) -> Option { if self.len() == 0 { return None;