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

@ -73,10 +73,7 @@ pub(crate) mod fragments {
// Parse a meta item , which excluded [], e.g : #[ MetaItem ]
pub(crate) fn meta_item(p: &mut Parser) {
fn is_delimiter(p: &mut Parser) -> bool {
match p.current() {
T!['{'] | T!['('] | T!['['] => true,
_ => false,
}
matches!(p.current(), T!['{'] | T!['('] | T!['['])
}
if is_delimiter(p) {

View file

@ -41,10 +41,7 @@ fn path(p: &mut Parser, mode: Mode) {
path_segment(p, mode, true);
let mut qual = path.complete(p, PATH);
loop {
let use_tree = match p.nth(2) {
T![*] | T!['{'] => true,
_ => false,
};
let use_tree = matches!(p.nth(2), T![*] | T!['{']);
if p.at(T![::]) && !use_tree {
let path = qual.precede(p);
p.bump(T![::]);

View file

@ -169,10 +169,7 @@ fn is_where_predicate(p: &mut Parser) -> bool {
}
fn is_where_clause_end(p: &mut Parser) -> bool {
match p.current() {
T!['{'] | T![;] | T![=] => true,
_ => false,
}
matches!(p.current(), T!['{'] | T![;] | T![=])
}
fn where_predicate(p: &mut Parser) {

View file

@ -20,9 +20,6 @@ impl From<SyntaxKind> for u16 {
impl SyntaxKind {
pub fn is_trivia(self) -> bool {
match self {
SyntaxKind::WHITESPACE | SyntaxKind::COMMENT => true,
_ => false,
}
matches!(self, SyntaxKind::WHITESPACE | SyntaxKind::COMMENT)
}
}