From e75e2ae5b6b6b1364368ceb3d4081b6508b2f001 Mon Sep 17 00:00:00 2001 From: Veetaha Date: Sun, 28 Jun 2020 04:02:03 +0300 Subject: Simlify with matches!() --- crates/ra_syntax/src/ast/expr_extensions.rs | 5 +---- crates/ra_syntax/src/ast/extensions.rs | 16 ++++++++-------- crates/ra_syntax/src/parsing/reparsing.rs | 5 +---- 3 files changed, 10 insertions(+), 16 deletions(-) (limited to 'crates/ra_syntax/src') diff --git a/crates/ra_syntax/src/ast/expr_extensions.rs b/crates/ra_syntax/src/ast/expr_extensions.rs index 7771d6759..db5438d68 100644 --- a/crates/ra_syntax/src/ast/expr_extensions.rs +++ b/crates/ra_syntax/src/ast/expr_extensions.rs @@ -399,10 +399,7 @@ impl ast::BlockExpr { Some(it) => it, None => return true, }; - match parent.kind() { - FN_DEF | IF_EXPR | WHILE_EXPR | LOOP_EXPR | EFFECT_EXPR => false, - _ => true, - } + !matches!(parent.kind(), FN_DEF | IF_EXPR | WHILE_EXPR | LOOP_EXPR | EFFECT_EXPR) } } diff --git a/crates/ra_syntax/src/ast/extensions.rs b/crates/ra_syntax/src/ast/extensions.rs index 98c38d009..662c6f73e 100644 --- a/crates/ra_syntax/src/ast/extensions.rs +++ b/crates/ra_syntax/src/ast/extensions.rs @@ -459,16 +459,16 @@ impl ast::RangePat { impl ast::TokenTree { pub fn left_delimiter_token(&self) -> Option { - self.syntax().first_child_or_token()?.into_token().filter(|it| match it.kind() { - T!['{'] | T!['('] | T!['['] => true, - _ => false, - }) + self.syntax() + .first_child_or_token()? + .into_token() + .filter(|it| matches!(it.kind(), T!['{'] | T!['('] | T!['['])) } pub fn right_delimiter_token(&self) -> Option { - self.syntax().last_child_or_token()?.into_token().filter(|it| match it.kind() { - T!['}'] | T![')'] | T![']'] => true, - _ => false, - }) + self.syntax() + .last_child_or_token()? + .into_token() + .filter(|it| matches!(it.kind(), T!['}'] | T![')'] | T![']'])) } } diff --git a/crates/ra_syntax/src/parsing/reparsing.rs b/crates/ra_syntax/src/parsing/reparsing.rs index edbc190f8..ed5a42ea3 100644 --- a/crates/ra_syntax/src/parsing/reparsing.rs +++ b/crates/ra_syntax/src/parsing/reparsing.rs @@ -120,10 +120,7 @@ fn get_text_after_edit(element: SyntaxElement, edit: &Indel) -> String { } fn is_contextual_kw(text: &str) -> bool { - match text { - "auto" | "default" | "union" => true, - _ => false, - } + matches!(text, "auto" | "default" | "union") } fn find_reparsable_node(node: &SyntaxNode, range: TextRange) -> Option<(SyntaxNode, Reparser)> { -- cgit v1.2.3