md_grid 0.2.1

A simple library for storing and iterating through data in a rectangular grid.
Documentation
  • Coverage
  • 0%
    0 out of 24 items documented0 out of 18 items with examples
  • Size
  • Source code size: 22.56 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 1.83 MB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 11s Average build duration of successful builds.
  • all releases: 11s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • Repository
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • mdenchev

This is a library for representing game boards with utilities for doing useful game related functions.

Currently only a simple rectangular grid is supported.

extern crate grid;
extern crate prettytable;
use grid::Grid;

fn main() {
    let data = vec![
        vec![1, 2, 3, 4],
        vec![5, 6, 7, 8],
        vec![9, 10, 11, 12],
    ];
    let grid = Grid::<usize>::new_from(data);

    // neighbors around 6
    let mut iter = grid.eight_neighbors(1, 1);
    iter.for_each(|cell| println!("{}", cell));

    // for debugging, you can printout the whole grid
    // via pretty table pkg
    grid.pretty_table().printstd();
}

With output:

1
2
3
5
7
9

10
11
+---+----+----+----+
| 1 | 2  | 3  | 4  |
+---+----+----+----+
| 5 | 6  | 7  | 8  |
+---+----+----+----+
| 9 | 10 | 11 | 12 |
+---+----+----+----+

Also checkout the chessboard example: cargo run --example chessboard --features="prettytable"