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

tuple destruction to initialized variables #60343

Closed
ghost opened this issue Apr 27, 2019 · 1 comment
Closed

tuple destruction to initialized variables #60343

ghost opened this issue Apr 27, 2019 · 1 comment

Comments

@ghost
Copy link

ghost commented Apr 27, 2019

(I hope I am in the right repo and this isn't a duplicate or a dump question :)

Currently (using rust 1.34.1) destructing a tuple is only possible to newly created variables.

let mut foo = 0;
let mut bar = 1;

(foo, bar) = (2,3);

This code fails with following error.

 |
 | (foo, bar) = (2,3);
 | ^^^^^^^^^^^^^^^^^^ left-hand of expression not valid

But this is valid.

let mut foo = 0;
let mut bar = 1;

let test = (2,3);

foo = test.0;
bar = test.1;

I think it would be intuitive to destruct into already known variables rather than having to create a new one.

@varkor
Copy link
Member

varkor commented Apr 27, 2019

This is rust-lang/rfcs#372.

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