From 611d9e399c95268a3daf41bd6cbcc55391ccff87 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?H=C3=A9ctor=20Ram=C3=B3n=20Jim=C3=A9nez?= Date: Wed, 29 Apr 2020 23:55:15 +0200 Subject: [PATCH] Clarify `tick` logic in `game_of_life` --- examples/game_of_life/src/main.rs | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/examples/game_of_life/src/main.rs b/examples/game_of_life/src/main.rs index fb12afa1..3989e3ea 100644 --- a/examples/game_of_life/src/main.rs +++ b/examples/game_of_life/src/main.rs @@ -200,14 +200,12 @@ mod grid { let is_populated = self.alive_cells.contains(&(i, j)); match amount { - 2 if is_populated => {} + 2 | 3 if is_populated => {} 3 => { - if !is_populated { - self.alive_cells.insert((i, j)); - } + let _ = self.alive_cells.insert((i, j)); } _ if is_populated => { - self.alive_cells.remove(&(i, j)); + let _ = self.alive_cells.remove(&(i, j)); } _ => {} }