I tried coding the paper game of battleships, where a battlefield is an enum array. I couldn't find a way to initialize the array.
enum Tile {
Water,
Debris,
Ship(Rc<Ship>),
}
fn main() {
let mut a = [[Tile::Water; 10]; 10]; //Tile::Water doesn't implement Copy (the compiler is dumb)
let mut b: [[Tile; 10]; 10];
for i in 1..10 {
for j in 1..10 {
b[i][j] = Tile::Water;
}
} //use of possibly uninitialized b (I'm trying to initialize it)
}
How can this be done? I am not looking for another solution for the game, it is just an example here.