From bbcca4f735870246c8ed8ce1a29af100e09b0a6f Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Thu, 22 Aug 2019 15:20:07 +0300 Subject: make ast object safe --- crates/ra_assists/src/ast_editor.rs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'crates/ra_assists') 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 { } impl AstEditor { - pub fn new(node: N) -> AstEditor { + pub fn new(node: N) -> AstEditor + where + N: Clone, + { AstEditor { original_ast: node.clone(), ast: node } } @@ -379,7 +382,7 @@ impl AstBuilder { fn ast_node_from_file_text(text: &str) -> N { let parse = SourceFile::parse(text); - let res = parse.tree().syntax().descendants().find_map(N::cast).unwrap().to_owned(); + let res = parse.tree().syntax().descendants().find_map(N::cast).unwrap(); res } -- cgit v1.2.3