From 7c3b1bd867271ecbae8f0e84b36835b4e6f8021e Mon Sep 17 00:00:00 2001 From: a14m Date: Thu, 8 Apr 2021 00:49:28 +0200 Subject: Fix indexing the correct vec Due to most test using square planes it didn't have much effect till debugging Display trait cropped printing. The effect of this bug was that the universe was cropped to match the height length but calculations were not wrong, just cropped --- CLI/rust/src/game_of_life/simulation/universe.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CLI/rust/src/game_of_life/simulation/universe.rs b/CLI/rust/src/game_of_life/simulation/universe.rs index dab1915..6059dc6 100644 --- a/CLI/rust/src/game_of_life/simulation/universe.rs +++ b/CLI/rust/src/game_of_life/simulation/universe.rs @@ -82,7 +82,7 @@ mod display { impl Index for Universe { type Output = Plane; fn index(&self, idx: isize) -> &Plane { - let len = self.current.0.len() as isize; + let len = self.current.len() as isize; &self.current[circular_index(idx, len) as isize] } } @@ -170,7 +170,7 @@ impl Universe { /// set the current state to the next future generation pub(crate) fn evolve(mut self) -> Self { for row in 0..self.current.len() { - for col in 0..self.current.0.len() as isize { + for col in 0..self.current[row].len() as isize { let living_neighbors = self .neighbors(row, col) .iter() -- cgit v1.2.3