Enable clippy::search_is_some (#8748)

This PR enables the
[`clippy::search_is_some`](https://rust-lang.github.io/rust-clippy/master/index.html#/search_is_some)
rule and fixes the outstanding violations.

Release Notes:

- N/A
This commit is contained in:
Marshall Bowers 2024-03-02 21:46:30 -05:00 committed by GitHub
parent 3ab16d8012
commit 328c8a94b3
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 7 additions and 9 deletions

View File

@ -6444,10 +6444,9 @@ impl Editor {
&& !movement::is_inside_word(&display_map, display_range.end))
{
// TODO: This is n^2, because we might check all the selections
if selections
if !selections
.iter()
.find(|selection| selection.range().overlaps(&offset_range))
.is_none()
.any(|selection| selection.range().overlaps(&offset_range))
{
next_selected_range = Some(offset_range);
break;

View File

@ -8,7 +8,7 @@ struct FeatureFlags {
impl FeatureFlags {
fn has_flag(&self, flag: &str) -> bool {
self.staff || self.flags.iter().find(|f| f.as_str() == flag).is_some()
self.staff || self.flags.iter().any(|f| f.as_str() == flag)
}
}

View File

@ -16,7 +16,7 @@ impl SearchHistory {
}
if let Some(previously_searched) = self.history.last_mut() {
if search_string.find(previously_searched.as_str()).is_some() {
if search_string.contains(previously_searched.as_str()) {
*previously_searched = search_string;
self.selected = Some(self.history.len() - 1);
return;

View File

@ -357,8 +357,8 @@ mod tests {
.collect::<Vec<_>>();
assert_eq!(result.len(), 2);
assert!(result.iter().find(|(k, _)| k == &&"baa").is_some());
assert!(result.iter().find(|(k, _)| k == &&"baaab").is_some());
assert!(result.iter().any(|(k, _)| k == &&"baa"));
assert!(result.iter().any(|(k, _)| k == &&"baaab"));
let result = map
.iter_from(&"c")
@ -366,7 +366,7 @@ mod tests {
.collect::<Vec<_>>();
assert_eq!(result.len(), 1);
assert!(result.iter().find(|(k, _)| k == &&"c").is_some());
assert!(result.iter().any(|(k, _)| k == &&"c"));
}
#[test]

View File

@ -113,7 +113,6 @@ fn run_clippy(args: ClippyArgs) -> Result<()> {
"clippy::redundant_guards",
"clippy::redundant_locals",
"clippy::reversed_empty_ranges",
"clippy::search_is_some",
"clippy::single_range_in_vec_init",
"clippy::suspicious_to_owned",
"clippy::type_complexity",