5
在迭代元组数组时,Rust为什么不解构元组?例如:为什么迭代元组数组时,元组不能解构?
let x: &[(usize, usize)] = &[...];
for (a,b) in x.iter() {
...
}
导致错误:
error: type mismatch resolving `<core::slice::Iter<'_, (usize, usize)> as core::iter::Iterator>::Item == (_, _)`:
expected &-ptr,
found tuple [E0271]