Skip to content

Commit b0775b2

Browse files
kamadoruedadarichey
authored andcommitted
refactor: use matches macro
1 parent 2567fca commit b0775b2

File tree

3 files changed

+4
-16
lines changed

3 files changed

+4
-16
lines changed

src/kinds.rs

+2-8
Original file line numberDiff line numberDiff line change
@@ -107,10 +107,7 @@ use SyntaxKind::*;
107107
impl SyntaxKind {
108108
/// Returns true if this token is a literal, such as an integer or a string
109109
pub fn is_literal(self) -> bool {
110-
match self {
111-
TOKEN_FLOAT | TOKEN_INTEGER | TOKEN_PATH | TOKEN_URI => true,
112-
_ => false,
113-
}
110+
matches!(self, TOKEN_FLOAT | TOKEN_INTEGER | TOKEN_PATH | TOKEN_URI)
114111
}
115112
/// Returns true if this token should be used as a function argument.
116113
/// ```ignore
@@ -132,9 +129,6 @@ impl SyntaxKind {
132129
/// Returns true if this token is a comment, whitespace, or similar, and
133130
/// should be skipped over by the parser.
134131
pub fn is_trivia(self) -> bool {
135-
match self {
136-
TOKEN_COMMENT | TOKEN_ERROR | TOKEN_WHITESPACE => true,
137-
_ => false,
138-
}
132+
matches!(self, TOKEN_COMMENT | TOKEN_ERROR | TOKEN_WHITESPACE)
139133
}
140134
}

src/lib.rs

+1-4
Original file line numberDiff line numberDiff line change
@@ -103,9 +103,6 @@ mod tests {
103103
#[test]
104104
fn t_macro() {
105105
assert_eq!(T![@], SyntaxKind::TOKEN_AT);
106-
assert!(match SyntaxKind::TOKEN_PAREN_OPEN {
107-
T!["("] => true,
108-
_ => false,
109-
});
106+
assert!(matches!(SyntaxKind::TOKEN_PAREN_OPEN, T!["("]));
110107
}
111108
}

src/tokenizer.rs

+1-4
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,7 @@ enum IdentType {
1313
}
1414

1515
fn is_valid_path_char(c: char) -> bool {
16-
match c {
17-
'a'..='z' | 'A'..='Z' | '0'..='9' | '/' | '_' | '.' | '+' | '-' => true,
18-
_ => false,
19-
}
16+
matches!(c, 'a'..='z' | 'A'..='Z' | '0'..='9' | '/' | '_' | '.' | '+' | '-')
2017
}
2118

2219
fn is_valid_uri_char(c: char) -> bool {

0 commit comments

Comments
 (0)