From ae7e55c1dd801c60092205ec8890179e10a47814 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matthias=20Kr=C3=BCger?= Date: Sun, 21 Mar 2021 13:13:34 +0100 Subject: clippy::complexity simplifications related to Iterators --- .../ide_assists/src/handlers/convert_comment_block.rs | 5 ++--- crates/ide_assists/src/handlers/expand_glob_import.rs | 19 +++++++------------ crates/ide_assists/src/handlers/reorder_impl.rs | 2 +- 3 files changed, 10 insertions(+), 16 deletions(-) (limited to 'crates/ide_assists') diff --git a/crates/ide_assists/src/handlers/convert_comment_block.rs b/crates/ide_assists/src/handlers/convert_comment_block.rs index cdc45fc42..9dc3ee28f 100644 --- a/crates/ide_assists/src/handlers/convert_comment_block.rs +++ b/crates/ide_assists/src/handlers/convert_comment_block.rs @@ -1,5 +1,4 @@ use itertools::Itertools; -use std::convert::identity; use syntax::{ ast::{ self, @@ -140,7 +139,7 @@ fn relevant_line_comments(comment: &ast::Comment) -> Vec { .filter(|s| !skippable(s)) .map(|not| not.into_token().and_then(Comment::cast).filter(same_prefix)) .take_while(|opt_com| opt_com.is_some()) - .filter_map(identity) + .flatten() .skip(1); // skip the first element so we don't duplicate it in next_comments let next_comments = comment @@ -149,7 +148,7 @@ fn relevant_line_comments(comment: &ast::Comment) -> Vec { .filter(|s| !skippable(s)) .map(|not| not.into_token().and_then(Comment::cast).filter(same_prefix)) .take_while(|opt_com| opt_com.is_some()) - .filter_map(identity); + .flatten(); let mut comments: Vec<_> = prev_comments.collect(); comments.reverse(); diff --git a/crates/ide_assists/src/handlers/expand_glob_import.rs b/crates/ide_assists/src/handlers/expand_glob_import.rs index 83aa11d52..98389e4f7 100644 --- a/crates/ide_assists/src/handlers/expand_glob_import.rs +++ b/crates/ide_assists/src/handlers/expand_glob_import.rs @@ -136,18 +136,13 @@ impl Refs { .into_iter() .filter(|r| { if let Def::ModuleDef(ModuleDef::Trait(tr)) = r.def { - if tr - .items(ctx.db()) - .into_iter() - .find(|ai| { - if let AssocItem::Function(f) = *ai { - Def::ModuleDef(ModuleDef::Function(f)).is_referenced_in(ctx) - } else { - false - } - }) - .is_some() - { + if tr.items(ctx.db()).into_iter().any(|ai| { + if let AssocItem::Function(f) = ai { + Def::ModuleDef(ModuleDef::Function(f)).is_referenced_in(ctx) + } else { + false + } + }) { return true; } } diff --git a/crates/ide_assists/src/handlers/reorder_impl.rs b/crates/ide_assists/src/handlers/reorder_impl.rs index edf4b0bfe..f976e73ad 100644 --- a/crates/ide_assists/src/handlers/reorder_impl.rs +++ b/crates/ide_assists/src/handlers/reorder_impl.rs @@ -95,7 +95,7 @@ fn compute_method_ranks(path: &ast::Path, ctx: &AssistContext) -> Option None, }) .enumerate() - .map(|(idx, func)| ((func.name(ctx.db()).to_string(), idx))) + .map(|(idx, func)| (func.name(ctx.db()).to_string(), idx)) .collect(), ) } -- cgit v1.2.3