From a224e0087d4faf8fbfae8074c384c4ba03217ba5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luiz=20Carlos=20Mour=C3=A3o=20Paes=20de=20Carvalho?= Date: Wed, 10 Mar 2021 00:32:25 -0300 Subject: fix: code formatting --- .../src/handlers/convert_iter_for_each_to_for.rs | 30 ++++++++++++++-------- 1 file changed, 20 insertions(+), 10 deletions(-) (limited to 'crates/ide_assists/src/handlers/convert_iter_for_each_to_for.rs') diff --git a/crates/ide_assists/src/handlers/convert_iter_for_each_to_for.rs b/crates/ide_assists/src/handlers/convert_iter_for_each_to_for.rs index 7903a18fa..73ef44685 100644 --- a/crates/ide_assists/src/handlers/convert_iter_for_each_to_for.rs +++ b/crates/ide_assists/src/handlers/convert_iter_for_each_to_for.rs @@ -1,5 +1,8 @@ use ide_db::helpers::FamousDefs; -use syntax::{AstNode, ast::{self, make, ArgListOwner, edit::AstNodeEdit}}; +use syntax::{ + ast::{self, edit::AstNodeEdit, make, ArgListOwner}, + AstNode, +}; use crate::{AssistContext, AssistId, AssistKind, Assists}; @@ -31,16 +34,20 @@ pub(crate) fn convert_iter_for_each_to_for(acc: &mut Assists, ctx: &AssistContex ast::Expr::MethodCallExpr(expr) => { closure = match expr.arg_list()?.args().next()? { ast::Expr::ClosureExpr(expr) => expr, - _ => { return None; } + _ => { + return None; + } }; - + expr - }, + } ast::Expr::ClosureExpr(expr) => { closure = expr; ast::MethodCallExpr::cast(closure.syntax().ancestors().nth(2)?)? - }, - _ => { return None; } + } + _ => { + return None; + } }; 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 let block = match body { ast::Expr::BlockExpr(block) => block, - _ => make::block_expr(Vec::new(), Some(body)) - }.reset_indent().indent(original_indentation); + _ => make::block_expr(Vec::new(), Some(body)), + } + .reset_indent() + .indent(original_indentation); let expr_for_loop = make::expr_for_loop(param, parent, block); builder.replace_ast(total_expr, expr_for_loop) @@ -187,6 +196,7 @@ fn main() { r#" fn main() { value.$0for_each(|x| println!("{}", x)); -}"#) +}"#, + ) } -} \ No newline at end of file +} -- cgit v1.2.3