Skip to content

Commit a224e00

Browse files
committed
fix: code formatting
1 parent b7f9771 commit a224e00

File tree

1 file changed

+20
-10
lines changed

1 file changed

+20
-10
lines changed

crates/ide_assists/src/handlers/convert_iter_for_each_to_for.rs

Lines changed: 20 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
use ide_db::helpers::FamousDefs;
2-
use syntax::{AstNode, ast::{self, make, ArgListOwner, edit::AstNodeEdit}};
2+
use syntax::{
3+
ast::{self, edit::AstNodeEdit, make, ArgListOwner},
4+
AstNode,
5+
};
36

47
use crate::{AssistContext, AssistId, AssistKind, Assists};
58

@@ -31,16 +34,20 @@ pub(crate) fn convert_iter_for_each_to_for(acc: &mut Assists, ctx: &AssistContex
3134
ast::Expr::MethodCallExpr(expr) => {
3235
closure = match expr.arg_list()?.args().next()? {
3336
ast::Expr::ClosureExpr(expr) => expr,
34-
_ => { return None; }
37+
_ => {
38+
return None;
39+
}
3540
};
36-
41+
3742
expr
38-
},
43+
}
3944
ast::Expr::ClosureExpr(expr) => {
4045
closure = expr;
4146
ast::MethodCallExpr::cast(closure.syntax().ancestors().nth(2)?)?
42-
},
43-
_ => { return None; }
47+
}
48+
_ => {
49+
return None;
50+
}
4451
};
4552

4653
let (total_expr, parent) = validate_method_call_expr(&ctx.sema, total_expr)?;
@@ -58,8 +65,10 @@ pub(crate) fn convert_iter_for_each_to_for(acc: &mut Assists, ctx: &AssistContex
5865

5966
let block = match body {
6067
ast::Expr::BlockExpr(block) => block,
61-
_ => make::block_expr(Vec::new(), Some(body))
62-
}.reset_indent().indent(original_indentation);
68+
_ => make::block_expr(Vec::new(), Some(body)),
69+
}
70+
.reset_indent()
71+
.indent(original_indentation);
6372

6473
let expr_for_loop = make::expr_for_loop(param, parent, block);
6574
builder.replace_ast(total_expr, expr_for_loop)
@@ -187,6 +196,7 @@ fn main() {
187196
r#"
188197
fn main() {
189198
value.$0for_each(|x| println!("{}", x));
190-
}"#)
199+
}"#,
200+
)
191201
}
192-
}
202+
}

0 commit comments

Comments
 (0)