diff options
author | Aleksey Kladov <[email protected]> | 2018-11-01 10:41:04 +0000 |
---|---|---|
committer | Aleksey Kladov <[email protected]> | 2018-11-01 10:41:20 +0000 |
commit | d685a9b564fe524865cda5713c527aaeb1ca6b1d (patch) | |
tree | 67908a8602d4eee25d78d6b467df8d431e29950c /crates/ra_syntax/src/ast/generated.rs.tera | |
parent | 3ec9f958b39b23b945dd60088843d19fe6cef2d7 (diff) |
Use From to get an owned AST
Diffstat (limited to 'crates/ra_syntax/src/ast/generated.rs.tera')
-rw-r--r-- | crates/ra_syntax/src/ast/generated.rs.tera | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/crates/ra_syntax/src/ast/generated.rs.tera b/crates/ra_syntax/src/ast/generated.rs.tera index d30038cba..1321f0def 100644 --- a/crates/ra_syntax/src/ast/generated.rs.tera +++ b/crates/ra_syntax/src/ast/generated.rs.tera | |||
@@ -17,15 +17,18 @@ use crate::{ | |||
17 | pub struct {{ node }}Node(SyntaxNode); | 17 | pub struct {{ node }}Node(SyntaxNode); |
18 | 18 | ||
19 | impl {{ node }}Node { | 19 | impl {{ node }}Node { |
20 | pub fn new(ast: {{ node }}) -> {{ node }}Node { | ||
21 | let syntax = ast.syntax().owned(); | ||
22 | {{ node }}Node(syntax) | ||
23 | } | ||
24 | pub fn ast(&self) -> {{ node }} { | 20 | pub fn ast(&self) -> {{ node }} { |
25 | {{ node }}::cast(self.0.borrowed()).unwrap() | 21 | {{ node }}::cast(self.0.borrowed()).unwrap() |
26 | } | 22 | } |
27 | } | 23 | } |
28 | 24 | ||
25 | impl<'a> From<{{ node }}<'a>> for {{ node }}Node { | ||
26 | fn from(ast: {{ node}}<'a>) -> {{ node }}Node { | ||
27 | let syntax = ast.syntax().owned(); | ||
28 | {{ node }}Node(syntax) | ||
29 | } | ||
30 | } | ||
31 | |||
29 | {%- if methods.enum %} | 32 | {%- if methods.enum %} |
30 | #[derive(Debug, Clone, Copy)] | 33 | #[derive(Debug, Clone, Copy)] |
31 | pub enum {{ node }}<'a> { | 34 | pub enum {{ node }}<'a> { |