Closed
Description
let arr = [Box::new(1), Box::new(2), Box::new(3)];
let [a, b, c] = arr;
fails with
<anon>:5:13: 5:14 error: use of moved value: `arr[..]` [E0382]
<anon>:5 let [a, b, c] = arr;
^
<anon>:5:10: 5:11 note: `arr[..]` moved here because it has type `Box<i32>`, which is moved by default
<anon>:5 let [a, b, c] = arr;
^
<anon>:5:10: 5:11 help: use `ref` to override
while the following work fine:
let arr = [Box::new(1)];
let [a] = arr;
enum Dummy<T> {
Val([T; 2]),
}
let arr = [Box::new(1), Box::new(2)];
let Dummy::Val([a, b]) = Dummy::Val(arr);