Crate cell_grid

Source
Expand description

A simple 2d grid container

§Example

use cell_grid::DynamicGrid;

// Create a new empty grid
let mut grid: DynamicGrid<i32> = DynamicGrid::new();

// Push rows
grid.push_row([1, 2]).unwrap();
grid.push_row([3, 4]).unwrap();

// Access by coordinate
assert_eq!(grid.get(0, 0), Some(&1));
assert_eq!(grid.get(1, 0), Some(&2));
assert_eq!(grid.get(0, 1), Some(&3));
assert_eq!(grid.get(1, 1), Some(&4));

// Iterate the content
assert_eq!(grid.cells().copied().collect::<Vec<_>>(), vec![1, 2, 3, 4]);
assert_eq!(grid.rows().collect::<Vec<_>>(), vec![&[1, 2], &[3, 4]]);

It is also possible to:

§Features

  • std: (enabled by default) enable use of the standard library. Must be disabled for no_std crates.

Structs§