I’m trying to initialize a fixed-size array of some nullable, non-copyable type, like an Option
for some kind of Thing
. I’d
This is the "keep it simple" answer: just type out all the values:
struct Thing;
const SIZE: usize = 5;
fn main() {
let array: [Option>; SIZE] = [None, None, None, None, None];
}
You could also use a build script to generate this code for you. For an example of this, see: