mirror of
https://github.com/fish-shell/fish-shell.git
synced 2026-05-21 03:21:16 -03:00
Simplify call to is_sorted_by()
I con no longer reproduce an error/warning for this.
This commit is contained in:
@@ -172,9 +172,7 @@ fn compute_gaps(&self) -> Vec<SourceRange> {
|
||||
tok_ranges.push(SourceRange::new(self.state.source.len(), 0));
|
||||
|
||||
// Our tokens should be sorted.
|
||||
assert!(IsSorted::is_sorted_by(&tok_ranges, |x, y| Some(
|
||||
range_compare(*x, *y)
|
||||
)));
|
||||
assert!(tok_ranges.is_sorted_by(|x, y| Some(range_compare(*x, *y))));
|
||||
|
||||
// For each range, add a gap range between the previous range and this range.
|
||||
let mut gaps = vec![];
|
||||
@@ -474,9 +472,7 @@ fn gap_text_to(&self, end: usize) -> SourceRange {
|
||||
fn range_contained_error(&self, r: SourceRange) -> bool {
|
||||
let errs = self.errors.as_ref().unwrap();
|
||||
let range_is_before = |x: SourceRange, y: SourceRange| x.end().cmp(&y.start());
|
||||
assert!(IsSorted::is_sorted_by(errs, |&x, &y| Some(
|
||||
range_is_before(x, y)
|
||||
)));
|
||||
assert!(errs.is_sorted_by(|&x, &y| Some(range_is_before(x, y))));
|
||||
errs.partition_point(|&range| range_is_before(range, r).is_lt()) != errs.len()
|
||||
}
|
||||
|
||||
|
||||
@@ -7,7 +7,6 @@ pub trait IsSomeAnd {
|
||||
#[allow(clippy::wrong_self_convention)]
|
||||
fn is_none_or(self, s: impl FnOnce(Self::Type) -> bool) -> bool;
|
||||
}
|
||||
|
||||
impl<T> IsSomeAnd for Option<T> {
|
||||
type Type = T;
|
||||
fn is_some_and(self, f: impl FnOnce(T) -> bool) -> bool {
|
||||
@@ -30,7 +29,6 @@ pub trait IsOkAnd {
|
||||
#[allow(clippy::wrong_self_convention)]
|
||||
fn is_ok_and(self, s: impl FnOnce(Self::Type) -> bool) -> bool;
|
||||
}
|
||||
|
||||
impl<T, E> IsOkAnd for Result<T, E> {
|
||||
type Type = T;
|
||||
type Error = E;
|
||||
@@ -60,9 +58,3 @@ fn is_sorted_by(&self, pred: impl Fn(&T, &T) -> Option<std::cmp::Ordering>) -> b
|
||||
IsSorted::is_sorted_by(&self.as_slice(), pred)
|
||||
}
|
||||
}
|
||||
impl<T> IsSorted for &Vec<T> {
|
||||
type T = T;
|
||||
fn is_sorted_by(&self, pred: impl Fn(&T, &T) -> Option<std::cmp::Ordering>) -> bool {
|
||||
IsSorted::is_sorted_by(&self.as_slice(), pred)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user