From 5f8b37563e6d82872a18afaf4d9ca25a4ebefac0 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Sat, 29 Feb 2020 13:49:43 +0100 Subject: Cleanup editing API --- crates/ra_syntax/src/ast/edit.rs | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) (limited to 'crates/ra_syntax/src/ast/edit.rs') diff --git a/crates/ra_syntax/src/ast/edit.rs b/crates/ra_syntax/src/ast/edit.rs index 0e78d8b63..d2630e9e9 100644 --- a/crates/ra_syntax/src/ast/edit.rs +++ b/crates/ra_syntax/src/ast/edit.rs @@ -276,7 +276,7 @@ pub fn replace_descendants( .into_iter() .map(|(from, to)| (from.syntax().clone().into(), to.syntax().clone().into())) .collect::>(); - let new_syntax = algo::replace_descendants(parent.syntax(), &|n| map.get(n).cloned()); + let new_syntax = algo::replace_descendants(parent.syntax(), |n| map.get(n).cloned()); N::cast(new_syntax).unwrap() } @@ -331,7 +331,7 @@ impl IndentLevel { ) }) .collect(); - algo::replace_descendants(&node, &|n| replacements.get(n).cloned()) + algo::replace_descendants(&node, |n| replacements.get(n).cloned()) } pub fn decrease_indent(self, node: N) -> N { @@ -359,7 +359,7 @@ impl IndentLevel { ) }) .collect(); - algo::replace_descendants(&node, &|n| replacements.get(n).cloned()) + algo::replace_descendants(&node, |n| replacements.get(n).cloned()) } } @@ -389,7 +389,7 @@ fn insert_children( position: InsertPosition, to_insert: impl IntoIterator, ) -> N { - let new_syntax = algo::insert_children(parent.syntax(), position, &mut to_insert.into_iter()); + let new_syntax = algo::insert_children(parent.syntax(), position, to_insert); N::cast(new_syntax).unwrap() } @@ -404,8 +404,7 @@ fn replace_children( to_replace: RangeInclusive, to_insert: impl IntoIterator, ) -> N { - let new_syntax = - algo::replace_children(parent.syntax(), to_replace, &mut to_insert.into_iter()); + let new_syntax = algo::replace_children(parent.syntax(), to_replace, to_insert); N::cast(new_syntax).unwrap() } -- cgit v1.2.3