diff options
author | Aleksey Kladov <[email protected]> | 2019-08-22 13:20:07 +0100 |
---|---|---|
committer | Aleksey Kladov <[email protected]> | 2019-08-23 13:06:47 +0100 |
commit | bbcca4f735870246c8ed8ce1a29af100e09b0a6f (patch) | |
tree | 3d0df9bf5c25cdf241426901c78c2b7f9bb8e38b /crates/ra_assists/src | |
parent | e055cfacdfe3b3451484dae5d6ed08aefba133ca (diff) |
make ast object safe
Diffstat (limited to 'crates/ra_assists/src')
-rw-r--r-- | crates/ra_assists/src/ast_editor.rs | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/crates/ra_assists/src/ast_editor.rs b/crates/ra_assists/src/ast_editor.rs index 5b6952426..076df98f2 100644 --- a/crates/ra_assists/src/ast_editor.rs +++ b/crates/ra_assists/src/ast_editor.rs | |||
@@ -19,7 +19,10 @@ pub struct AstEditor<N: AstNode> { | |||
19 | } | 19 | } |
20 | 20 | ||
21 | impl<N: AstNode> AstEditor<N> { | 21 | impl<N: AstNode> AstEditor<N> { |
22 | pub fn new(node: N) -> AstEditor<N> { | 22 | pub fn new(node: N) -> AstEditor<N> |
23 | where | ||
24 | N: Clone, | ||
25 | { | ||
23 | AstEditor { original_ast: node.clone(), ast: node } | 26 | AstEditor { original_ast: node.clone(), ast: node } |
24 | } | 27 | } |
25 | 28 | ||
@@ -379,7 +382,7 @@ impl AstBuilder<ast::MatchArmList> { | |||
379 | 382 | ||
380 | fn ast_node_from_file_text<N: AstNode>(text: &str) -> N { | 383 | fn ast_node_from_file_text<N: AstNode>(text: &str) -> N { |
381 | let parse = SourceFile::parse(text); | 384 | let parse = SourceFile::parse(text); |
382 | let res = parse.tree().syntax().descendants().find_map(N::cast).unwrap().to_owned(); | 385 | let res = parse.tree().syntax().descendants().find_map(N::cast).unwrap(); |
383 | res | 386 | res |
384 | } | 387 | } |
385 | 388 | ||