Skip to content

Commit

Permalink
Rollup merge of #102977 - lukas-code:is-sorted-hrtb, r=m-ou-se
Browse files Browse the repository at this point in the history
remove HRTB from `[T]::is_sorted_by{,_key}`

Changes the signature of `[T]::is_sorted_by{,_key}` to match `[T]::binary_search_by{,_key}` and make code like rust-lang/rust#53485 (comment) compile.

Tracking issue: rust-lang/rust#53485

~~Do we need an ACP for something like this?~~ Edit: Filed ACP here: rust-lang/libs-team#121
  • Loading branch information
Manishearth authored Nov 18, 2022
2 parents 3cfc190 + c8dd62c commit 1cd4c2f
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions core/src/slice/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3752,9 +3752,9 @@ impl<T> [T] {
/// [`is_sorted`]: slice::is_sorted
#[unstable(feature = "is_sorted", reason = "new API", issue = "53485")]
#[must_use]
pub fn is_sorted_by<F>(&self, mut compare: F) -> bool
pub fn is_sorted_by<'a, F>(&'a self, mut compare: F) -> bool
where
F: FnMut(&T, &T) -> Option<Ordering>,
F: FnMut(&'a T, &'a T) -> Option<Ordering>,
{
self.iter().is_sorted_by(|a, b| compare(*a, *b))
}
Expand All @@ -3778,9 +3778,9 @@ impl<T> [T] {
#[inline]
#[unstable(feature = "is_sorted", reason = "new API", issue = "53485")]
#[must_use]
pub fn is_sorted_by_key<F, K>(&self, f: F) -> bool
pub fn is_sorted_by_key<'a, F, K>(&'a self, f: F) -> bool
where
F: FnMut(&T) -> K,
F: FnMut(&'a T) -> K,
K: PartialOrd,
{
self.iter().is_sorted_by_key(f)
Expand Down

0 comments on commit 1cd4c2f

Please sign in to comment.