From 0cfa9eb44562f3c3b840a87ab4cfecb45e06765d Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Mon, 30 Mar 2020 12:28:22 +0200 Subject: [PATCH] Use IntoIter --- crates/ra_assists/src/handlers/fill_match_arms.rs | 3 +-- crates/ra_syntax/src/ast/edit.rs | 8 ++++---- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/crates/ra_assists/src/handlers/fill_match_arms.rs b/crates/ra_assists/src/handlers/fill_match_arms.rs index 5f279d25ad3..41bb97928db 100644 --- a/crates/ra_assists/src/handlers/fill_match_arms.rs +++ b/crates/ra_assists/src/handlers/fill_match_arms.rs @@ -97,8 +97,7 @@ pub(crate) fn fill_match_arms(ctx: AssistCtx) -> Option { } ctx.add_assist(AssistId("fill_match_arms"), "Fill match arms", |edit| { - let new_arm_list = - match_arm_list.remove_placeholder().append_arms(missing_arms.into_iter()); + let new_arm_list = match_arm_list.remove_placeholder().append_arms(missing_arms); edit.target(match_expr.syntax().text_range()); edit.set_cursor(expr.syntax().text_range().start()); diff --git a/crates/ra_syntax/src/ast/edit.rs b/crates/ra_syntax/src/ast/edit.rs index baf9a1b4b20..3d023f1891b 100644 --- a/crates/ra_syntax/src/ast/edit.rs +++ b/crates/ra_syntax/src/ast/edit.rs @@ -80,12 +80,12 @@ fn make_multiline(node: N) -> N impl ast::ItemList { #[must_use] - pub fn append_items(&self, items: impl Iterator) -> ast::ItemList { + pub fn append_items(&self, items: impl IntoIterator) -> ast::ItemList { let mut res = self.clone(); if !self.syntax().text().contains_char('\n') { res = make_multiline(res); } - items.for_each(|it| res = res.append_item(it)); + items.into_iter().for_each(|it| res = res.append_item(it)); res } @@ -339,13 +339,13 @@ pub fn remove(&self) -> SyntaxRewriter<'static> { impl ast::MatchArmList { #[must_use] - pub fn append_arms(&self, items: impl Iterator) -> ast::MatchArmList { + pub fn append_arms(&self, items: impl IntoIterator) -> ast::MatchArmList { let mut res = self.clone(); res = res.strip_if_only_whitespace(); if !res.syntax().text().contains_char('\n') { res = make_multiline(res); } - items.for_each(|it| res = res.append_arm(it)); + items.into_iter().for_each(|it| res = res.append_arm(it)); res }