This repository was archived by the owner on May 28, 2025. It is now read-only.
File tree 4 files changed +866
-0
lines changed 4 files changed +866
-0
lines changed Load Diff Large diffs are not rendered by default.
Original file line number Diff line number Diff line change @@ -121,6 +121,7 @@ mod handlers {
121
121
mod convert_iter_for_each_to_for;
122
122
mod convert_let_else_to_match;
123
123
mod convert_tuple_struct_to_named_struct;
124
+ mod convert_named_struct_to_tuple_struct;
124
125
mod convert_to_guarded_return;
125
126
mod convert_two_arm_bool_match_to_matches_macro;
126
127
mod convert_while_to_loop;
@@ -218,6 +219,7 @@ mod handlers {
218
219
convert_iter_for_each_to_for:: convert_iter_for_each_to_for,
219
220
convert_iter_for_each_to_for:: convert_for_loop_with_for_each,
220
221
convert_let_else_to_match:: convert_let_else_to_match,
222
+ convert_named_struct_to_tuple_struct:: convert_named_struct_to_tuple_struct,
221
223
convert_to_guarded_return:: convert_to_guarded_return,
222
224
convert_tuple_struct_to_named_struct:: convert_tuple_struct_to_named_struct,
223
225
convert_two_arm_bool_match_to_matches_macro:: convert_two_arm_bool_match_to_matches_macro,
Original file line number Diff line number Diff line change @@ -232,6 +232,7 @@ fn assist_order_field_struct() {
232
232
assert_eq ! ( assists. next( ) . expect( "expected assist" ) . label, "Generate a getter method" ) ;
233
233
assert_eq ! ( assists. next( ) . expect( "expected assist" ) . label, "Generate a mut getter method" ) ;
234
234
assert_eq ! ( assists. next( ) . expect( "expected assist" ) . label, "Generate a setter method" ) ;
235
+ assert_eq ! ( assists. next( ) . expect( "expected assist" ) . label, "Convert to tuple struct" ) ;
235
236
assert_eq ! ( assists. next( ) . expect( "expected assist" ) . label, "Add `#[derive]`" ) ;
236
237
}
237
238
Original file line number Diff line number Diff line change @@ -407,6 +407,47 @@ fn main() {
407
407
)
408
408
}
409
409
410
+ #[ test]
411
+ fn doctest_convert_named_struct_to_tuple_struct ( ) {
412
+ check_doc_test (
413
+ "convert_named_struct_to_tuple_struct" ,
414
+ r#####"
415
+ struct Point$0 { x: f32, y: f32 }
416
+
417
+ impl Point {
418
+ pub fn new(x: f32, y: f32) -> Self {
419
+ Point { x, y }
420
+ }
421
+
422
+ pub fn x(&self) -> f32 {
423
+ self.x
424
+ }
425
+
426
+ pub fn y(&self) -> f32 {
427
+ self.y
428
+ }
429
+ }
430
+ "##### ,
431
+ r#####"
432
+ struct Point(f32, f32);
433
+
434
+ impl Point {
435
+ pub fn new(x: f32, y: f32) -> Self {
436
+ Point(x, y)
437
+ }
438
+
439
+ pub fn x(&self) -> f32 {
440
+ self.0
441
+ }
442
+
443
+ pub fn y(&self) -> f32 {
444
+ self.1
445
+ }
446
+ }
447
+ "##### ,
448
+ )
449
+ }
450
+
410
451
#[ test]
411
452
fn doctest_convert_to_guarded_return ( ) {
412
453
check_doc_test (
You can’t perform that action at this time.
0 commit comments