From 86ca928a3fbeedd99fa151082dcf6f1456ad4939 Mon Sep 17 00:00:00 2001 From: JOLIMAITRE Matthieu Date: Wed, 31 Aug 2022 18:50:44 +0200 Subject: [PATCH] fixed warnings and added metadata for publication --- Cargo.toml | 8 +++++--- README.md | 8 ++++++++ src/world/hashed_world.rs | 19 +++++++------------ 3 files changed, 20 insertions(+), 15 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 3e7ca97..77b3566 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -2,8 +2,10 @@ name = "golrs" version = "0.1.0" edition = "2021" - -# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html +description = "a TUI for vizualising a rust implementation of the game of life." +authors = ["Matthieu JOLIMAITRE "] +license = "MIT" +repository = "https://github.com/MajorBarnulf/golrs" [dependencies] -termion = "1.5.6" +termion = "1.5" diff --git a/README.md b/README.md index e8bba6d..52a1570 100644 --- a/README.md +++ b/README.md @@ -7,3 +7,11 @@ Game Of Life RuSt ## Description This is a TUI for vizualising a rust implementation of the game of life + +## Installation + +With cargo + +```sh +cargo install glors +``` diff --git a/src/world/hashed_world.rs b/src/world/hashed_world.rs index c9cba70..cd48e0d 100644 --- a/src/world/hashed_world.rs +++ b/src/world/hashed_world.rs @@ -21,15 +21,11 @@ impl Chunk { } fn get_actives(&self) -> impl Iterator + '_ { - self.cells - .iter() - .enumerate() - .map(|(x, row)| { - row.iter().enumerate().filter_map(move |(y, cell)| { - cell.is_active().then_some(pos!(x as i32, y as i32)) - }) - }) - .flatten() + self.cells.iter().enumerate().flat_map(|(x, row)| { + row.iter() + .enumerate() + .filter_map(move |(y, cell)| cell.is_active().then_some(pos!(x as i32, y as i32))) + }) } } @@ -108,10 +104,9 @@ impl World for HashedWorld { fn actives(&self) -> Vec { self.chunks .iter() - .map(|(ChunkPos(chunk_pos), chunk)| { - chunk.get_actives().map(|pos| chunk_pos.clone() + pos) + .flat_map(|(ChunkPos(chunk_pos), chunk)| { + chunk.get_actives().map(|pos| *chunk_pos + pos) }) - .flatten() .collect() } }