The Universe
A flat Vec of cells, neighbour counting, and a tick function.
#[wasm_bindgen]
pub struct Universe {
width: u32,
height: u32,
cells: Vec<Cell>,
}
Store the grid as one flat Vec, indexed row * width + column. A Vec<Vec<Cell>> costs
you an extra pointer chase per row and scatters the data across the heap.
#[repr(u8)] on the Cell enum lets you count live neighbours by adding the cells
directly โ Dead = 0, Alive = 1. Small representation choices like this are most of the
performance difference in a tight loop.
Use modular arithmetic for wrapping edges so there is no special case at the borders.