mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-28 12:54:58 +00:00
Use IntoIter
This commit is contained in:
parent
d2ea3f25b5
commit
0cfa9eb445
2 changed files with 5 additions and 6 deletions
|
@ -97,8 +97,7 @@ pub(crate) fn fill_match_arms(ctx: AssistCtx) -> Option<Assist> {
|
||||||
}
|
}
|
||||||
|
|
||||||
ctx.add_assist(AssistId("fill_match_arms"), "Fill match arms", |edit| {
|
ctx.add_assist(AssistId("fill_match_arms"), "Fill match arms", |edit| {
|
||||||
let new_arm_list =
|
let new_arm_list = match_arm_list.remove_placeholder().append_arms(missing_arms);
|
||||||
match_arm_list.remove_placeholder().append_arms(missing_arms.into_iter());
|
|
||||||
|
|
||||||
edit.target(match_expr.syntax().text_range());
|
edit.target(match_expr.syntax().text_range());
|
||||||
edit.set_cursor(expr.syntax().text_range().start());
|
edit.set_cursor(expr.syntax().text_range().start());
|
||||||
|
|
|
@ -80,12 +80,12 @@ where
|
||||||
|
|
||||||
impl ast::ItemList {
|
impl ast::ItemList {
|
||||||
#[must_use]
|
#[must_use]
|
||||||
pub fn append_items(&self, items: impl Iterator<Item = ast::ImplItem>) -> ast::ItemList {
|
pub fn append_items(&self, items: impl IntoIterator<Item = ast::ImplItem>) -> ast::ItemList {
|
||||||
let mut res = self.clone();
|
let mut res = self.clone();
|
||||||
if !self.syntax().text().contains_char('\n') {
|
if !self.syntax().text().contains_char('\n') {
|
||||||
res = make_multiline(res);
|
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
|
res
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -339,13 +339,13 @@ impl ast::UseTree {
|
||||||
|
|
||||||
impl ast::MatchArmList {
|
impl ast::MatchArmList {
|
||||||
#[must_use]
|
#[must_use]
|
||||||
pub fn append_arms(&self, items: impl Iterator<Item = ast::MatchArm>) -> ast::MatchArmList {
|
pub fn append_arms(&self, items: impl IntoIterator<Item = ast::MatchArm>) -> ast::MatchArmList {
|
||||||
let mut res = self.clone();
|
let mut res = self.clone();
|
||||||
res = res.strip_if_only_whitespace();
|
res = res.strip_if_only_whitespace();
|
||||||
if !res.syntax().text().contains_char('\n') {
|
if !res.syntax().text().contains_char('\n') {
|
||||||
res = make_multiline(res);
|
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
|
res
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue