From 08aa8e1de717425ebf49796df1515d9fbd8b2e3e Mon Sep 17 00:00:00 2001 From: Mikhail Rakhmanov Date: Sun, 24 May 2020 14:53:12 +0200 Subject: Further refactoring under review comments --- .../src/handlers/extract_struct_from_enum_variant.rs | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) (limited to 'crates/ra_assists') diff --git a/crates/ra_assists/src/handlers/extract_struct_from_enum_variant.rs b/crates/ra_assists/src/handlers/extract_struct_from_enum_variant.rs index dd2fd57a7..a36587633 100644 --- a/crates/ra_assists/src/handlers/extract_struct_from_enum_variant.rs +++ b/crates/ra_assists/src/handlers/extract_struct_from_enum_variant.rs @@ -6,7 +6,6 @@ use ra_syntax::{ ast::{self, AstNode, NameOwner}, SourceFile, SyntaxNode, TextRange, TextSize, }; -use stdx::format_to; use crate::{ assist_context::{AssistBuilder, AssistDirector}, @@ -58,7 +57,7 @@ pub(crate) fn extract_struct_from_enum(acc: &mut Assists, ctx: &AssistContext) - let definition = Definition::ModuleDef(ModuleDef::EnumVariant(variant_hir)); let res = definition.find_usages(&ctx.db, None); let start_offset = variant.parent_enum().syntax().text_range().start(); - let mut visited_modules_set: FxHashSet = FxHashSet::default(); + let mut visited_modules_set = FxHashSet::default(); visited_modules_set.insert(current_module); for reference in res { let source_file = ctx.sema.parse(reference.file_range.file_id); @@ -132,10 +131,7 @@ fn extract_struct_def( } else { "".to_string() }; - let mut buf = String::new(); - - format_to!( - buf, + let struct_def = format!( r#"{}struct {}{}; {}"#, @@ -145,7 +141,7 @@ fn extract_struct_def( indent ); edit.perform(file_id, |builder| { - builder.insert(start_offset, buf); + builder.insert(start_offset, struct_def); }); Some(()) } -- cgit v1.2.3