From bb16cad9dc09d7f0feaa3e7736f882973e869f8d Mon Sep 17 00:00:00 2001 From: Johannes Altmanninger Date: Wed, 6 Dec 2023 11:03:00 +0100 Subject: [PATCH] Simplify call to is_sorted_by() I con no longer reproduce an error/warning for this. --- fish-rust/src/fish_indent.rs | 8 ++------ fish-rust/src/future.rs | 8 -------- 2 files changed, 2 insertions(+), 14 deletions(-) diff --git a/fish-rust/src/fish_indent.rs b/fish-rust/src/fish_indent.rs index e1bb891a2..2bac06545 100755 --- a/fish-rust/src/fish_indent.rs +++ b/fish-rust/src/fish_indent.rs @@ -172,9 +172,7 @@ fn compute_gaps(&self) -> Vec { 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() } diff --git a/fish-rust/src/future.rs b/fish-rust/src/future.rs index d811c17df..97b8d7e5c 100644 --- a/fish-rust/src/future.rs +++ b/fish-rust/src/future.rs @@ -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 IsSomeAnd for Option { 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 IsOkAnd for Result { type Type = T; type Error = E; @@ -60,9 +58,3 @@ fn is_sorted_by(&self, pred: impl Fn(&T, &T) -> Option) -> b IsSorted::is_sorted_by(&self.as_slice(), pred) } } -impl IsSorted for &Vec { - type T = T; - fn is_sorted_by(&self, pred: impl Fn(&T, &T) -> Option) -> bool { - IsSorted::is_sorted_by(&self.as_slice(), pred) - } -}