I have made an "improved" version which accepts:
new bindings (to be prefixed by
let inside the tuple);
improved error message when using tuples with too many elements;
arbitrary "place expressions" (e.g.,
*(&mut ...) where to perform the assignments;
fn main ()
let mut a = [0, 0];
(a,), a, let z,
) = (
(42,), 27, 0,
I have added (not so many) comments to make the whole macro mess slightly more readable.
The only remaining issue is that there is no type-checking performed on the right hand side of the assignment, so it currently accepts and silently discards extra elements when the tuple on the right is too long.
Here is a version that fixes it:
- it errors on tuple lengths mismatch