mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-30 13:51:31 +00:00
support upcastig in AST enum
This commit is contained in:
parent
c110e72a11
commit
666303faf3
2 changed files with 407 additions and 0 deletions
|
@ -38,6 +38,15 @@ pub enum {{ node }}Kind<'a> {
|
|||
{%- endfor %}
|
||||
}
|
||||
|
||||
{%- for kind in methods.enum %}
|
||||
impl<'a> From<&'a {{ kind }}> for &'a {{ node }} {
|
||||
fn from(n: &'a {{ kind }}) -> &'a {{ node }} {
|
||||
{{ node }}::cast(&n.syntax).unwrap()
|
||||
}
|
||||
}
|
||||
{%- endfor %}
|
||||
|
||||
|
||||
impl AstNode for {{ node }} {
|
||||
fn cast(syntax: &SyntaxNode) -> Option<&Self> {
|
||||
match syntax.kind() {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue