Simlify with matches!()

This commit is contained in:
Veetaha 2020-06-28 04:02:03 +03:00
parent 513924a7e0
commit e75e2ae5b6
20 changed files with 32 additions and 98 deletions

View file

@ -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)
}
}

View file

@ -459,16 +459,16 @@ impl ast::RangePat {
impl ast::TokenTree {
pub fn left_delimiter_token(&self) -> Option<SyntaxToken> {
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<SyntaxToken> {
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![']']))
}
}