Skip to content

Commit 99541be

Browse files
committed
Fix slice binary search signature mismatch
The signature for `std::slice::binary_search` is now parameterized over `Borrow`, as in `core::SliceExt`
1 parent 94e884b commit 99541be

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

src/libcollections/slice.rs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1046,8 +1046,9 @@ impl<T> [T] {
10461046
/// assert!(match r { Ok(1...4) => true, _ => false, });
10471047
/// ```
10481048
#[stable(feature = "rust1", since = "1.0.0")]
1049-
pub fn binary_search(&self, x: &T) -> Result<usize, usize>
1050-
where T: Ord
1049+
pub fn binary_search<Q: ?Sized>(&self, x: &Q) -> Result<usize, usize>
1050+
where T: Borrow<Q>,
1051+
Q: Ord
10511052
{
10521053
core_slice::SliceExt::binary_search(self, x)
10531054
}
@@ -1123,9 +1124,10 @@ impl<T> [T] {
11231124
/// ```
11241125
#[stable(feature = "slice_binary_search_by_key", since = "1.10.0")]
11251126
#[inline]
1126-
pub fn binary_search_by_key<'a, B, F>(&'a self, b: &B, f: F) -> Result<usize, usize>
1127+
pub fn binary_search_by_key<'a, B, F, Q: ?Sized>(&'a self, b: &Q, f: F) -> Result<usize, usize>
11271128
where F: FnMut(&'a T) -> B,
1128-
B: Ord
1129+
B: Borrow<Q>,
1130+
Q: Ord
11291131
{
11301132
core_slice::SliceExt::binary_search_by_key(self, b, f)
11311133
}

0 commit comments

Comments
 (0)