Skip to content

feat: ide-assists, Unwrap array #19775

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from

Conversation

A4-Tacks
Copy link
Contributor

Like Unwrap tuple

fn main() {
    $0let [foo, bar] = ["Foo", "Bar"];
}

->

fn main() {
    let foo = "Foo";
    let bar = "Bar";
}

Verified

This commit was signed with the committer’s verified signature.
Aaron1011 Aaron Hill
@rustbot rustbot added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label May 10, 2025
@ChayimFriedman2
Copy link
Contributor

I don't know if we should have this, because in my experience arrays (unlike tuples) are rarely used just to assign values to two (or more) variables. That is, when you destructure an array, you have an array and not building it in the same expression. Also, if we decide we want this, this likely needs code deduplication from "unwrap tuple".

@A4-Tacks
Copy link
Contributor Author

Using an array can obtain consistent types, making type inference more convenient.

@Veykril
Copy link
Member

Veykril commented Jun 2, 2025

I agree with Chayim, this assist does not seem that useful to have. Even the tuple case seems not too useful to me given you need a tuple pattern and a tuple expression on the respective sides which is already questionable imo.

@Veykril Veykril closed this Jun 2, 2025
@A4-Tacks A4-Tacks deleted the unwrap-array branch June 5, 2025 03:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-review Status: Awaiting review from the assignee but also interested parties.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants