diff options
| author | bors <bors@rust-lang.org> | 2016-08-08 21:51:01 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2016-08-08 21:51:01 -0700 |
| commit | 58c5716e2d2b89c18cf2ac996376c9720b65b51d (patch) | |
| tree | ff668068f110d0fe98421ac2bda1d74ad4452428 /src/libcore | |
| parent | 080e0e072f9c654893839cf1f7ea71dc153b08a9 (diff) | |
| parent | 6fd1752b251cef0325e13eb22f7991ce0f3688be (diff) | |
| download | rust-58c5716e2d2b89c18cf2ac996376c9720b65b51d.tar.gz rust-58c5716e2d2b89c18cf2ac996376c9720b65b51d.zip | |
Auto merge of #34762 - creativcoder:slice-ext, r=alexcrichton
extend lifetime on binary_search_by_key of SliceExt trait Fixes #34683.
Diffstat (limited to 'src/libcore')
| -rw-r--r-- | src/libcore/slice.rs | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/src/libcore/slice.rs b/src/libcore/slice.rs index d8a11581c3b..3141c289e93 100644 --- a/src/libcore/slice.rs +++ b/src/libcore/slice.rs @@ -105,11 +105,11 @@ pub trait SliceExt { fn binary_search(&self, x: &Self::Item) -> Result<usize, usize> where Self::Item: Ord; #[stable(feature = "core", since = "1.6.0")] - fn binary_search_by<F>(&self, f: F) -> Result<usize, usize> - where F: FnMut(&Self::Item) -> Ordering; + fn binary_search_by<'a, F>(&'a self, f: F) -> Result<usize, usize> + where F: FnMut(&'a Self::Item) -> Ordering; #[stable(feature = "slice_binary_search_by_key", since = "1.10.0")] - fn binary_search_by_key<B, F>(&self, b: &B, f: F) -> Result<usize, usize> - where F: FnMut(&Self::Item) -> B, + fn binary_search_by_key<'a, B, F>(&'a self, b: &B, f: F) -> Result<usize, usize> + where F: FnMut(&'a Self::Item) -> B, B: Ord; #[stable(feature = "core", since = "1.6.0")] fn len(&self) -> usize; @@ -301,8 +301,8 @@ impl<T> SliceExt for [T] { self as *const [T] as *const T } - fn binary_search_by<F>(&self, mut f: F) -> Result<usize, usize> where - F: FnMut(&T) -> Ordering + fn binary_search_by<'a, F>(&'a self, mut f: F) -> Result<usize, usize> + where F: FnMut(&'a T) -> Ordering { let mut base = 0usize; let mut s = self; @@ -514,8 +514,8 @@ impl<T> SliceExt for [T] { } #[inline] - fn binary_search_by_key<B, F>(&self, b: &B, mut f: F) -> Result<usize, usize> - where F: FnMut(&Self::Item) -> B, + fn binary_search_by_key<'a, B, F>(&'a self, b: &B, mut f: F) -> Result<usize, usize> + where F: FnMut(&'a Self::Item) -> B, B: Ord { self.binary_search_by(|k| f(k).cmp(b)) |
