Skip to content

Commit d8e7419

Browse files
committed
Generate and use TargetInfo::new
1 parent 2e4a4f1 commit d8e7419

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

crates/ide-assists/src/handlers/generate_function.rs

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,18 @@ struct TargetInfo {
8686
insert_offset: TextSize,
8787
}
8888

89+
impl TargetInfo {
90+
fn new(
91+
target_module: Option<Module>,
92+
adt_name: Option<hir::Name>,
93+
target: GeneratedFunctionTarget,
94+
file: FileId,
95+
insert_offset: TextSize,
96+
) -> Self {
97+
Self { target_module, adt_name, target, file, insert_offset }
98+
}
99+
}
100+
89101
fn fn_target_info(
90102
ctx: &AssistContext<'_>,
91103
path: ast::Path,
@@ -123,7 +135,7 @@ fn fn_target_info(
123135
get_fn_target(ctx, &target_module, call.clone())?
124136
}
125137
};
126-
Some(TargetInfo { target_module, adt_name, target, file, insert_offset })
138+
Some(TargetInfo::new(target_module, adt_name, target, file, insert_offset))
127139
}
128140

129141
fn gen_method(acc: &mut Assists, ctx: &AssistContext<'_>) -> Option<()> {
@@ -427,7 +439,7 @@ fn assoc_fn_target_info(
427439
let (impl_, file) = get_adt_source(ctx, &adt, fn_name)?;
428440
let (target, insert_offset) = get_method_target(ctx, &module, &impl_)?;
429441
let adt_name = if impl_.is_none() { Some(adt.name(ctx.sema.db)) } else { None };
430-
Some(TargetInfo { target_module, adt_name, target, file, insert_offset })
442+
Some(TargetInfo::new(target_module, adt_name, target, file, insert_offset))
431443
}
432444

433445
fn get_insert_offset(target: &GeneratedFunctionTarget) -> TextSize {

0 commit comments

Comments
 (0)