fixed warnings and added metadata for publication

This commit is contained in:
JOLIMAITRE Matthieu 2022-08-31 18:50:44 +02:00
parent 9cf5a5b56d
commit 86ca928a3f
3 changed files with 20 additions and 15 deletions

View file

@ -2,8 +2,10 @@
name = "golrs" name = "golrs"
version = "0.1.0" version = "0.1.0"
edition = "2021" edition = "2021"
description = "a TUI for vizualising a rust implementation of the game of life."
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html authors = ["Matthieu JOLIMAITRE <matthieu@imagevo.fr>"]
license = "MIT"
repository = "https://github.com/MajorBarnulf/golrs"
[dependencies] [dependencies]
termion = "1.5.6" termion = "1.5"

View file

@ -7,3 +7,11 @@ Game Of Life RuSt
## Description ## Description
This is a TUI for vizualising a rust implementation of the game of life This is a TUI for vizualising a rust implementation of the game of life
## Installation
With cargo
```sh
cargo install glors
```

View file

@ -21,15 +21,11 @@ impl Chunk {
} }
fn get_actives(&self) -> impl Iterator<Item = Pos> + '_ { fn get_actives(&self) -> impl Iterator<Item = Pos> + '_ {
self.cells self.cells.iter().enumerate().flat_map(|(x, row)| {
.iter() row.iter()
.enumerate() .enumerate()
.map(|(x, row)| { .filter_map(move |(y, cell)| cell.is_active().then_some(pos!(x as i32, y as i32)))
row.iter().enumerate().filter_map(move |(y, cell)| { })
cell.is_active().then_some(pos!(x as i32, y as i32))
})
})
.flatten()
} }
} }
@ -108,10 +104,9 @@ impl World for HashedWorld {
fn actives(&self) -> Vec<Pos> { fn actives(&self) -> Vec<Pos> {
self.chunks self.chunks
.iter() .iter()
.map(|(ChunkPos(chunk_pos), chunk)| { .flat_map(|(ChunkPos(chunk_pos), chunk)| {
chunk.get_actives().map(|pos| chunk_pos.clone() + pos) chunk.get_actives().map(|pos| *chunk_pos + pos)
}) })
.flatten()
.collect() .collect()
} }
} }