fix #5
This commit is contained in:
@@ -13,7 +13,7 @@ pub struct Grid {
|
|||||||
// 1
|
// 1
|
||||||
// 2
|
// 2
|
||||||
// ...
|
// ...
|
||||||
cells: [[Option<CellType>; LEN]; LEN],
|
cells: Vec<Vec<Option<CellType>>>,
|
||||||
/// (X, Y)
|
/// (X, Y)
|
||||||
pub selected_cell: (usize, usize),
|
pub selected_cell: (usize, usize),
|
||||||
}
|
}
|
||||||
@@ -28,12 +28,17 @@ impl std::fmt::Debug for Grid {
|
|||||||
|
|
||||||
impl Grid {
|
impl Grid {
|
||||||
pub fn new() -> Self {
|
pub fn new() -> Self {
|
||||||
// TODO this needs to be moved to the heap
|
let mut a = Vec::with_capacity(LEN);
|
||||||
let b: [[Option<CellType>; LEN]; LEN] =
|
for _ in 0..LEN {
|
||||||
core::array::from_fn(|_| core::array::from_fn(|_| None));
|
let mut b = Vec::with_capacity(LEN);
|
||||||
|
for _ in 0..LEN {
|
||||||
|
b.push(None)
|
||||||
|
}
|
||||||
|
a.push(b)
|
||||||
|
}
|
||||||
|
|
||||||
Self {
|
Self {
|
||||||
cells: b,
|
cells: a,
|
||||||
selected_cell: (0, 0),
|
selected_cell: (0, 0),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user