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 ++++++++-------- 2 files changed, 9 insertions(+), 12 deletions(-) (limited to 'crates/ra_syntax/src/ast') 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![']'])) } } -- cgit v1.2.3