|
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;
|
@@ -632,11 +629,10 @@ impl<T> SliceExt for [T] {
|
632 | 629 | m >= n && needle == &self[m-n..]
|
633 | 630 | }
|
634 | 631 |
|
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 |
638 | 634 | {
|
639 |
| - self.binary_search_by(|p| p.borrow().cmp(x)) |
| 635 | + self.binary_search_by(|p| p.cmp(x)) |
640 | 636 | }
|
641 | 637 |
|
642 | 638 | fn rotate(&mut self, mid: usize) {
|
@@ -674,12 +670,11 @@ impl<T> SliceExt for [T] {
|
674 | 670 | }
|
675 | 671 |
|
676 | 672 | #[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> |
678 | 674 | where F: FnMut(&'a Self::Item) -> B,
|
679 |
| - B: Borrow<Q>, |
680 |
| - Q: Ord |
| 675 | + B: Ord |
681 | 676 | {
|
682 |
| - self.binary_search_by(|k| f(k).borrow().cmp(b)) |
| 677 | + self.binary_search_by(|k| f(k).cmp(b)) |
683 | 678 | }
|
684 | 679 |
|
685 | 680 | #[inline]
|
|
0 commit comments