|
35 | 35 | // * The `raw` and `bytes` submodules. |
36 | 36 | // * Boilerplate trait implementations. |
37 | 37 |
|
38 | | -use borrow::Borrow; |
39 | 38 | use cmp::Ordering::{self, Less, Equal, Greater}; |
40 | 39 | use cmp; |
41 | 40 | use fmt; |
@@ -122,19 +121,17 @@ pub trait SliceExt { |
122 | 121 | fn as_ptr(&self) -> *const Self::Item; |
123 | 122 |
|
124 | 123 | #[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; |
128 | 126 |
|
129 | 127 | #[stable(feature = "core", since = "1.6.0")] |
130 | 128 | fn binary_search_by<'a, F>(&'a self, f: F) -> Result<usize, usize> |
131 | 129 | where F: FnMut(&'a Self::Item) -> Ordering; |
132 | 130 |
|
133 | 131 | #[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> |
135 | 133 | where F: FnMut(&'a Self::Item) -> B, |
136 | | - B: Borrow<Q>, |
137 | | - Q: Ord; |
| 134 | + B: Ord; |
138 | 135 |
|
139 | 136 | #[stable(feature = "core", since = "1.6.0")] |
140 | 137 | fn len(&self) -> usize; |
@@ -635,11 +632,10 @@ impl<T> SliceExt for [T] { |
635 | 632 | m >= n && needle == &self[m-n..] |
636 | 633 | } |
637 | 634 |
|
638 | | - fn binary_search<Q: ?Sized>(&self, x: &Q) -> Result<usize, usize> |
639 | | - where T: Borrow<Q>, |
640 | | - Q: Ord |
| 635 | + fn binary_search(&self, x: &T) -> Result<usize, usize> |
| 636 | + where T: Ord |
641 | 637 | { |
642 | | - self.binary_search_by(|p| p.borrow().cmp(x)) |
| 638 | + self.binary_search_by(|p| p.cmp(x)) |
643 | 639 | } |
644 | 640 |
|
645 | 641 | fn rotate(&mut self, mid: usize) { |
@@ -687,12 +683,11 @@ impl<T> SliceExt for [T] { |
687 | 683 | } |
688 | 684 |
|
689 | 685 | #[inline] |
690 | | - fn binary_search_by_key<'a, B, F, Q: ?Sized>(&'a self, b: &Q, mut f: F) -> Result<usize, usize> |
| 686 | + fn binary_search_by_key<'a, B, F>(&'a self, b: &B, mut f: F) -> Result<usize, usize> |
691 | 687 | where F: FnMut(&'a Self::Item) -> B, |
692 | | - B: Borrow<Q>, |
693 | | - Q: Ord |
| 688 | + B: Ord |
694 | 689 | { |
695 | | - self.binary_search_by(|k| f(k).borrow().cmp(b)) |
| 690 | + self.binary_search_by(|k| f(k).cmp(b)) |
696 | 691 | } |
697 | 692 |
|
698 | 693 | #[inline] |
|
0 commit comments