-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Open
Labels
A-assistsA-patternpattern handling related thingspattern handling related thingsE-mediumS-actionableSomeone could pick this issue up and work on it right nowSomeone could pick this issue up and work on it right nowfunA technically challenging issue with high impactA technically challenging issue with high impact
Description
- Tuple destructuring (implemented in feature: Destructure Tuple Assistย #9855)
- RecordStruct destructuring
- TupleStruct destructuring
- Improve the implementation Destructure assistย #8673 (comment)
It would be nice to have an assist for destructuring a binding into its "subbindings" as in, when you have a name to a tuple value have it destructure into names for each componenet of the tuple, same for structure fields etc. See IntelliJ's implementation here https://github.com/intellij-rust/intellij-rust/blob/master/src/main/kotlin/org/rust/ide/intentions/DestructureIntention.kt
Some examples for how it should work:
let foo$0 = (1, 2, 3);
let bar = foo.0;
let _ = foo.into();
becomes
let (_0, _1, _2) = (1, 2, 3);
let bar = _0;
let _ = (_0, _1, _2).into();
Similarly this should work for TupleStructs and RecordStructs:
struct Foo { bar: i32 }
let foo$0 = Foo { bar: 1 };
let bar = foo.bar;
let _ = foo.into();
becomes
struct Foo { bar: i32 }
let Foo { bar } = Foo { bar: 1 };
let bar = bar;
let _ = (Foo { bar }).into();
This should also respect private fields as well as #[non_exhaustive]
, putting ..
in that case for the fields that aren't exposed.
adsick and danielo515
Metadata
Metadata
Assignees
Labels
A-assistsA-patternpattern handling related thingspattern handling related thingsE-mediumS-actionableSomeone could pick this issue up and work on it right nowSomeone could pick this issue up and work on it right nowfunA technically challenging issue with high impactA technically challenging issue with high impact