Skip to content

Commit e513d7b

Browse files
committed
Replace tuple with TargetInfo struct
1 parent 30eabeb commit e513d7b

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

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

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ fn gen_fn(acc: &mut Assists, ctx: &AssistContext<'_>) -> Option<()> {
6161
}
6262

6363
let fn_name = &*name_ref.text();
64-
let (target_module, adt_name, target, file, insert_offset) =
64+
let TargetInfo { target_module, adt_name, target, file, insert_offset } =
6565
fn_target_info(path, ctx, &call, fn_name)?;
6666
let function_builder = FunctionBuilder::from_call(ctx, &call, fn_name, target_module, target)?;
6767
let text_range = call.syntax().text_range();
@@ -78,12 +78,20 @@ fn gen_fn(acc: &mut Assists, ctx: &AssistContext<'_>) -> Option<()> {
7878
)
7979
}
8080

81+
struct TargetInfo {
82+
target_module: Option<Module>,
83+
adt_name: Option<hir::Name>,
84+
target: GeneratedFunctionTarget,
85+
file: FileId,
86+
insert_offset: TextSize,
87+
}
88+
8189
fn fn_target_info(
8290
path: ast::Path,
8391
ctx: &AssistContext<'_>,
8492
call: &CallExpr,
8593
fn_name: &str,
86-
) -> Option<(Option<Module>, Option<hir::Name>, GeneratedFunctionTarget, FileId, TextSize)> {
94+
) -> Option<TargetInfo> {
8795
let mut target_module = None;
8896
let mut adt_name = None;
8997
let (target, file, insert_offset) = match path.qualifier() {
@@ -115,7 +123,7 @@ fn fn_target_info(
115123
get_fn_target(ctx, &target_module, call.clone())?
116124
}
117125
};
118-
Some((target_module, adt_name, target, file, insert_offset))
126+
Some(TargetInfo { target_module, adt_name, target, file, insert_offset })
119127
}
120128

121129
fn gen_method(acc: &mut Assists, ctx: &AssistContext<'_>) -> Option<()> {

0 commit comments

Comments
 (0)