@@ -86,6 +86,18 @@ struct TargetInfo {
86
86
insert_offset : TextSize ,
87
87
}
88
88
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
+
89
101
fn fn_target_info (
90
102
ctx : & AssistContext < ' _ > ,
91
103
path : ast:: Path ,
@@ -123,7 +135,7 @@ fn fn_target_info(
123
135
get_fn_target ( ctx, & target_module, call. clone ( ) ) ?
124
136
}
125
137
} ;
126
- Some ( TargetInfo { target_module, adt_name, target, file, insert_offset } )
138
+ Some ( TargetInfo :: new ( target_module, adt_name, target, file, insert_offset) )
127
139
}
128
140
129
141
fn gen_method ( acc : & mut Assists , ctx : & AssistContext < ' _ > ) -> Option < ( ) > {
@@ -427,7 +439,7 @@ fn assoc_fn_target_info(
427
439
let ( impl_, file) = get_adt_source ( ctx, & adt, fn_name) ?;
428
440
let ( target, insert_offset) = get_method_target ( ctx, & module, & impl_) ?;
429
441
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) )
431
443
}
432
444
433
445
fn get_insert_offset ( target : & GeneratedFunctionTarget ) -> TextSize {
0 commit comments