diff options
author | Aleksey Kladov <[email protected]> | 2019-02-24 13:57:05 +0000 |
---|---|---|
committer | Aleksey Kladov <[email protected]> | 2019-02-24 13:57:05 +0000 |
commit | 666303faf3c8b4215fde884451688084e298d6a8 (patch) | |
tree | a57e96d575a1e3cb5192b8a88128a6087b5a1479 /crates/ra_syntax/src/ast/generated.rs.tera | |
parent | c110e72a115bbec36413bd440812dfe9194c58e2 (diff) |
support upcastig in AST enum
Diffstat (limited to 'crates/ra_syntax/src/ast/generated.rs.tera')
-rw-r--r-- | crates/ra_syntax/src/ast/generated.rs.tera | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/crates/ra_syntax/src/ast/generated.rs.tera b/crates/ra_syntax/src/ast/generated.rs.tera index ca7a28581..e2d4856cf 100644 --- a/crates/ra_syntax/src/ast/generated.rs.tera +++ b/crates/ra_syntax/src/ast/generated.rs.tera | |||
@@ -38,6 +38,15 @@ pub enum {{ node }}Kind<'a> { | |||
38 | {%- endfor %} | 38 | {%- endfor %} |
39 | } | 39 | } |
40 | 40 | ||
41 | {%- for kind in methods.enum %} | ||
42 | impl<'a> From<&'a {{ kind }}> for &'a {{ node }} { | ||
43 | fn from(n: &'a {{ kind }}) -> &'a {{ node }} { | ||
44 | {{ node }}::cast(&n.syntax).unwrap() | ||
45 | } | ||
46 | } | ||
47 | {%- endfor %} | ||
48 | |||
49 | |||
41 | impl AstNode for {{ node }} { | 50 | impl AstNode for {{ node }} { |
42 | fn cast(syntax: &SyntaxNode) -> Option<&Self> { | 51 | fn cast(syntax: &SyntaxNode) -> Option<&Self> { |
43 | match syntax.kind() { | 52 | match syntax.kind() { |