mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-30 22:01:37 +00:00
Simlify with matches!()
This commit is contained in:
parent
513924a7e0
commit
e75e2ae5b6
20 changed files with 32 additions and 98 deletions
|
@ -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)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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![']']))
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue