diff options
-rw-r--r-- | crates/ra_assists/src/handlers/fill_match_arms.rs | 3 | ||||
-rw-r--r-- | 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 5f279d25a..41bb97928 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<Assist> { | |||
97 | } | 97 | } |
98 | 98 | ||
99 | ctx.add_assist(AssistId("fill_match_arms"), "Fill match arms", |edit| { | 99 | ctx.add_assist(AssistId("fill_match_arms"), "Fill match arms", |edit| { |
100 | let new_arm_list = | 100 | let new_arm_list = match_arm_list.remove_placeholder().append_arms(missing_arms); |
101 | match_arm_list.remove_placeholder().append_arms(missing_arms.into_iter()); | ||
102 | 101 | ||
103 | edit.target(match_expr.syntax().text_range()); | 102 | edit.target(match_expr.syntax().text_range()); |
104 | edit.set_cursor(expr.syntax().text_range().start()); | 103 | 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 baf9a1b4b..3d023f189 100644 --- a/crates/ra_syntax/src/ast/edit.rs +++ b/crates/ra_syntax/src/ast/edit.rs | |||
@@ -80,12 +80,12 @@ where | |||
80 | 80 | ||
81 | impl ast::ItemList { | 81 | impl ast::ItemList { |
82 | #[must_use] | 82 | #[must_use] |
83 | pub fn append_items(&self, items: impl Iterator<Item = ast::ImplItem>) -> ast::ItemList { | 83 | pub fn append_items(&self, items: impl IntoIterator<Item = ast::ImplItem>) -> ast::ItemList { |
84 | let mut res = self.clone(); | 84 | let mut res = self.clone(); |
85 | if !self.syntax().text().contains_char('\n') { | 85 | if !self.syntax().text().contains_char('\n') { |
86 | res = make_multiline(res); | 86 | res = make_multiline(res); |
87 | } | 87 | } |
88 | items.for_each(|it| res = res.append_item(it)); | 88 | items.into_iter().for_each(|it| res = res.append_item(it)); |
89 | res | 89 | res |
90 | } | 90 | } |
91 | 91 | ||
@@ -339,13 +339,13 @@ impl ast::UseTree { | |||
339 | 339 | ||
340 | impl ast::MatchArmList { | 340 | impl ast::MatchArmList { |
341 | #[must_use] | 341 | #[must_use] |
342 | pub fn append_arms(&self, items: impl Iterator<Item = ast::MatchArm>) -> ast::MatchArmList { | 342 | pub fn append_arms(&self, items: impl IntoIterator<Item = ast::MatchArm>) -> ast::MatchArmList { |
343 | let mut res = self.clone(); | 343 | let mut res = self.clone(); |
344 | res = res.strip_if_only_whitespace(); | 344 | res = res.strip_if_only_whitespace(); |
345 | if !res.syntax().text().contains_char('\n') { | 345 | if !res.syntax().text().contains_char('\n') { |
346 | res = make_multiline(res); | 346 | res = make_multiline(res); |
347 | } | 347 | } |
348 | items.for_each(|it| res = res.append_arm(it)); | 348 | items.into_iter().for_each(|it| res = res.append_arm(it)); |
349 | res | 349 | res |
350 | } | 350 | } |
351 | 351 | ||