Constructing fixed length arrays, as opposed to "Vec", seems to be surprisingly difficult. Can't use .collect() on a map. Even initializing an array of Option<usize> to all None is hard, because Option is not copyable. So:
let mut result: [Option<MeshCoords>;3] = [None,None,None];
Fortunately there are only 3 entries. Updating such a structure has to be done imperatively:
for axis in 0..3 {
if let Some(result_row) = &mut result[axis] {
result_row.uv_data_array = new_uv_row(result_row, axis as u8);
}
}
I have to use actual assignment statements. Oh, the shame!
For small array sizes, you can also use the Default implementation, which works with non-Copy types:
let xs: [Option<MeshCoords>; 3] = Default::default();
Unfortunately this breaks down for arrays of more than 32 elements, because there's already an unconditional impl<T> Default for [T; 0] and this would conflict with impl<T: Default, const N: usize> Default for [T; N], so core can't include the latter.