md_grid 0.2.1

A simple library for storing and iterating through data in a rectangular grid.
Documentation

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"