more matches! sites

This commit is contained in:
Kartavya Vashishtha 2022-08-07 17:37:50 +05:30
parent 70255029cf
commit a3fc4dbb04
No known key found for this signature in database
GPG Key ID: A50012C2324E5DF0

View File

@ -169,10 +169,7 @@ fn syntax(&self) -> &SyntaxNode { &self.syntax }
quote! {
impl AstNode for #name {
fn can_cast(kind: SyntaxKind) -> bool {
match kind {
#(#kinds)|* => true,
_ => false,
}
matches!(kind, #(#kinds)|*)
}
fn cast(syntax: SyntaxNode) -> Option<Self> {
let res = match syntax.kind() {
@ -253,10 +250,7 @@ pub fn new<T: ast::#trait_name>(node: T) -> #name {
}
impl AstNode for #name {
fn can_cast(kind: SyntaxKind) -> bool {
match kind {
#(#kinds)|* => true,
_ => false,
}
matches!(kind, #(#kinds)|*)
}
fn cast(syntax: SyntaxNode) -> Option<Self> {
Self::can_cast(syntax.kind()).then(|| #name { syntax })