mirror of
https://github.com/fish-shell/fish-shell.git
synced 2025-02-21 16:29:54 +08:00
Simplify call to is_sorted_by()
I con no longer reproduce an error/warning for this.
This commit is contained in:
parent
360c9043cb
commit
bb16cad9dc
@ -172,9 +172,7 @@ impl<'source, 'ast> PrettyPrinter<'source, 'ast> {
|
||||
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 @@ impl<'source, 'ast> PrettyPrinterState<'source, 'ast> {
|
||||
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 @@ impl<T> IsSorted for Vec<T> {
|
||||
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)
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user