Dynamic two-dimensional arrays for the Rust programming language.
Ingrid is a self-contained crate that provides a STL-like container for dynamic two-dimensional arrays for the Rust programming language. It comes with
algorithms and it’s expected to be generic and good enough for most use cases;
it was initially written to implement image pixels and grid-based games.
Features
It’s distributed under the MIT license. Feel free to use the way you like as
long as you keep the license around if you reuse the code.
To get a rough idea of what it is like to work with Ingrid, have a look at
the following snipped.
use ingrid::{Coordinate, Size};
use ingrid::Grid;
use ingrid::GridIterator;
use ingrid::{coord, size}; // Macros to shorten the syntax
// Create a grid with enough allocated memory to contain 9 elements.
let mut grid = Grid::<char>::with_capacity(size!(3, 3));
// Resize the grid to be 2x2 and fill it with a default value.
grid.resize(size!(2, 3), '😞');
// Change the content of the grid with the direct accessors.
grid[coord!(0, 0)] = '😄'; // Top-left element (first element)
grid[coord!(1, 2)] = '😄'; // Bottom-right element (last element)
// Insert a column right in the middle.
grid.insert_column(1, vec!['😮', '😮', '😮']);
// Iterate over the elements of the last row
for (coordinate, emoticon) in grid.row(2).iterator().enumerate_coordinate() {
println!("Emoticon at {:?} is {}", coordinate, emoticon);
}
Next step is to dig in the documentation, which comes with an excellent
introduction by the way.
Website: https://www.intjelic.me/project/ingrid
Repository: https://github.com/intjelic/ingrid
Crate: https://crates.io/crates/ingrid
Documentation: https://docs.rs/ingrid
Author: Jonahan De Wachter (dewachter.jonathan[at]gmail[dot]com)