Array of non-Copy

The situation here will probably get better as const generics get stabilized.

In the mean time there are a bunch of crates that can help. To add to the one already mentioned, https://crates.io/crates/arraytools allows things like

<[_; 32]>::generate(|| None)

EDIT: Many years later, since someone randomly :heart:'d this today, the way to do this now is std::array::from_fn(|_| None).

4 Likes