I'm trying to do something like
let (x, y) = returns_tuple();
but I do not want the elements of the tuple to be assigned to new variables. How is this done?
I'm trying to do something like
let (x, y) = returns_tuple();
but I do not want the elements of the tuple to be assigned to new variables. How is this done?
Rust doesn't have destructuring assignment. If you wan to reassign existing variables you will have to:
let tmp = returns_tuple();
x = tmp.0;
y = tmp.1;
Alright, thanks.
There is an RFC for destructuring assignment, and it is implemented on the nightly channel behind the #![feature(destructuring_assignment)]
feature gate.
Based on the tracking issue, the implementation is fairly complete and could be proposed for stabilization. The next step is for someone to write a stabilization report.
This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.