Skip to content

Commit ac15987

Browse files
committed
Remove Borrow bound from SliceExt::binary_search
1 parent b8ce1a3 commit ac15987

File tree

1 file changed

+10
-15
lines changed

1 file changed

+10
-15
lines changed

src/libcore/slice/mod.rs

+10-15
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@
3535
// * The `raw` and `bytes` submodules.
3636
// * Boilerplate trait implementations.
3737

38-
use borrow::Borrow;
3938
use cmp::Ordering::{self, Less, Equal, Greater};
4039
use cmp;
4140
use fmt;
@@ -122,19 +121,17 @@ pub trait SliceExt {
122121
fn as_ptr(&self) -> *const Self::Item;
123122

124123
#[stable(feature = "core", since = "1.6.0")]
125-
fn binary_search<Q: ?Sized>(&self, x: &Q) -> Result<usize, usize>
126-
where Self::Item: Borrow<Q>,
127-
Q: Ord;
124+
fn binary_search(&self, x: &Self::Item) -> Result<usize, usize>
125+
where Self::Item: Ord;
128126

129127
#[stable(feature = "core", since = "1.6.0")]
130128
fn binary_search_by<'a, F>(&'a self, f: F) -> Result<usize, usize>
131129
where F: FnMut(&'a Self::Item) -> Ordering;
132130

133131
#[stable(feature = "slice_binary_search_by_key", since = "1.10.0")]
134-
fn binary_search_by_key<'a, B, F, Q: ?Sized>(&'a self, b: &Q, f: F) -> Result<usize, usize>
132+
fn binary_search_by_key<'a, B, F>(&'a self, b: &B, f: F) -> Result<usize, usize>
135133
where F: FnMut(&'a Self::Item) -> B,
136-
B: Borrow<Q>,
137-
Q: Ord;
134+
B: Ord;
138135

139136
#[stable(feature = "core", since = "1.6.0")]
140137
fn len(&self) -> usize;
@@ -632,11 +629,10 @@ impl<T> SliceExt for [T] {
632629
m >= n && needle == &self[m-n..]
633630
}
634631

635-
fn binary_search<Q: ?Sized>(&self, x: &Q) -> Result<usize, usize>
636-
where T: Borrow<Q>,
637-
Q: Ord
632+
fn binary_search(&self, x: &T) -> Result<usize, usize>
633+
where T: Ord
638634
{
639-
self.binary_search_by(|p| p.borrow().cmp(x))
635+
self.binary_search_by(|p| p.cmp(x))
640636
}
641637

642638
fn rotate(&mut self, mid: usize) {
@@ -674,12 +670,11 @@ impl<T> SliceExt for [T] {
674670
}
675671

676672
#[inline]
677-
fn binary_search_by_key<'a, B, F, Q: ?Sized>(&'a self, b: &Q, mut f: F) -> Result<usize, usize>
673+
fn binary_search_by_key<'a, B, F>(&'a self, b: &B, mut f: F) -> Result<usize, usize>
678674
where F: FnMut(&'a Self::Item) -> B,
679-
B: Borrow<Q>,
680-
Q: Ord
675+
B: Ord
681676
{
682-
self.binary_search_by(|k| f(k).borrow().cmp(b))
677+
self.binary_search_by(|k| f(k).cmp(b))
683678
}
684679

685680
#[inline]

0 commit comments

Comments
 (0)