Skip to content
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

Feature request: destructure parameter code action/refactor #13104

Closed
adsick opened this issue Aug 24, 2022 · 2 comments
Closed

Feature request: destructure parameter code action/refactor #13104

adsick opened this issue Aug 24, 2022 · 2 comments

Comments

@adsick
Copy link

adsick commented Aug 24, 2022

so basically if you have

struct Vector {
    x: f32,
    y: f32,
    z: f32,
}

fn length(vector: Vector) -> f32 {
    let Vector { x, y, z } = vector;
    (x * x + y * y + z * z).sqrt()
}

the line

let Vector { x, y, z } = vector;

could be auto-generated by performing a code action on vector parameter, I think it would be handy for many devs out there so maybe add this functionality to RA?

@adsick
Copy link
Author

adsick commented Aug 24, 2022

upd: it also could be "destructure parameter inplace"... whoa, RA is already capable of it, cool!
I mean this:

fn length(Vector { x, y, z }: Vector) -> f32 {
    (x * x + y * y + z * z).sqrt()
}

@flodiebold
Copy link
Member

Duplicate of #8673 -- note that this already works for tuples, e.g. if you have fn length(v: (f32, f32, f32)).

@flodiebold flodiebold closed this as not planned Won't fix, can't repro, duplicate, stale Aug 24, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants