mirror of
https://github.com/rust-lang/rust-analyzer
synced 2024-12-25 12:33:33 +00:00
More compact
This commit is contained in:
parent
6fd2a12495
commit
9285cbffb6
3 changed files with 240 additions and 1438 deletions
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
|
@ -75,12 +75,7 @@ fn generate_tokens(kinds: KindsSrc<'_>, grammar: AstSrc<'_>) -> Result<String> {
|
|||
}
|
||||
|
||||
impl AstToken for #name {
|
||||
fn can_cast(kind: SyntaxKind) -> bool {
|
||||
match kind {
|
||||
#kind => true,
|
||||
_ => false,
|
||||
}
|
||||
}
|
||||
fn can_cast(kind: SyntaxKind) -> bool { kind == #kind }
|
||||
fn cast(syntax: SyntaxToken) -> Option<Self> {
|
||||
if Self::can_cast(syntax.kind()) { Some(Self { syntax }) } else { None }
|
||||
}
|
||||
|
@ -243,10 +238,7 @@ fn generate_nodes(kinds: KindsSrc<'_>, grammar: AstSrc<'_>) -> Result<String> {
|
|||
|
||||
impl AstNode for #name {
|
||||
fn can_cast(kind: SyntaxKind) -> bool {
|
||||
match kind {
|
||||
#kind => true,
|
||||
_ => false,
|
||||
}
|
||||
kind == #kind
|
||||
}
|
||||
fn cast(syntax: SyntaxNode) -> Option<Self> {
|
||||
if Self::can_cast(syntax.kind()) { Some(Self { syntax }) } else { None }
|
||||
|
|
Loading…
Reference in a new issue