From 1fb20e323106465bd2029ae8f6d4dac86422708c Mon Sep 17 00:00:00 2001 From: Edwin Cheng Date: Thu, 6 May 2021 22:39:51 +0800 Subject: Simplify --- crates/ide_completion/src/completions/trait_impl.rs | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/crates/ide_completion/src/completions/trait_impl.rs b/crates/ide_completion/src/completions/trait_impl.rs index 78fbfcd97..968c0254d 100644 --- a/crates/ide_completion/src/completions/trait_impl.rs +++ b/crates/ide_completion/src/completions/trait_impl.rs @@ -242,13 +242,9 @@ fn replacement_range(ctx: &CompletionContext, item: &SyntaxNode) -> TextRange { let first_child = item .children_with_tokens() .find(|child| { - let kind = child.kind(); - match kind { - SyntaxKind::COMMENT | SyntaxKind::WHITESPACE | SyntaxKind::ATTR => false, - _ => true, - } + !matches!(child.kind(), SyntaxKind::COMMENT | SyntaxKind::WHITESPACE | SyntaxKind::ATTR) }) - .unwrap_or(SyntaxElement::Node(item.clone())); + .unwrap_or_else(|| SyntaxElement::Node(item.clone())); TextRange::new(first_child.text_range().start(), ctx.source_range().end()) } -- cgit v1.2.3