From 2e0e26f720e24372f6152d3aba5a9dd2c3465df3 Mon Sep 17 00:00:00 2001 From: Alpha Chen Date: Sat, 16 Jan 2016 08:53:52 -0800 Subject: [PATCH] [rust] Use a Box for the light grid --- rust/src/day_06.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/rust/src/day_06.rs b/rust/src/day_06.rs index f8ae446..d8fbd6d 100644 --- a/rust/src/day_06.rs +++ b/rust/src/day_06.rs @@ -31,12 +31,12 @@ fn test_solve() { } struct LightGrid { - grid: [[bool; 1_000]; 1_000], + grid: Box<[bool; 1_000 * 1_000]>, } impl LightGrid { fn new() -> LightGrid { - LightGrid { grid: [[false; 1_000]; 1_000] } + LightGrid { grid: Box::new([false; 1_000 * 1_000]) } } fn turn_on(&mut self, rect: Rect) { @@ -90,13 +90,13 @@ impl Index for LightGrid { type Output = bool; fn index(&self, _index: Point) -> &bool { - &self.grid[_index.0][_index.1] + &self.grid[1_000 * _index.0 + _index.1] } } impl IndexMut for LightGrid { fn index_mut(&mut self, _index: Point) -> &mut bool { - &mut self.grid[_index.0][_index.1] + &mut self.grid[1_000 * _index.0 + _index.1] } }