From 6753e2ddd641cb99c962ae9f28a02d47c0f511d8 Mon Sep 17 00:00:00 2001 From: Rushmore75 Date: Tue, 11 Nov 2025 09:03:34 -0700 Subject: [PATCH] fix #5 --- src/app/calc.rs | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/src/app/calc.rs b/src/app/calc.rs index b9c6733..69833f7 100644 --- a/src/app/calc.rs +++ b/src/app/calc.rs @@ -13,7 +13,7 @@ pub struct Grid { // 1 // 2 // ... - cells: [[Option; LEN]; LEN], + cells: Vec>>, /// (X, Y) pub selected_cell: (usize, usize), } @@ -28,12 +28,17 @@ impl std::fmt::Debug for Grid { impl Grid { pub fn new() -> Self { - // TODO this needs to be moved to the heap - let b: [[Option; LEN]; LEN] = - core::array::from_fn(|_| core::array::from_fn(|_| None)); + let mut a = Vec::with_capacity(LEN); + for _ in 0..LEN { + let mut b = Vec::with_capacity(LEN); + for _ in 0..LEN { + b.push(None) + } + a.push(b) + } Self { - cells: b, + cells: a, selected_cell: (0, 0), } }