Crates.io | ingrid |
lib.rs | ingrid |
version | 0.1.0 |
source | src |
created_at | 2020-01-13 22:05:40.240212 |
updated_at | 2020-01-13 22:05:40.240212 |
description | Dynamic two-dimensional arrays with algorithms |
homepage | https://www.intjelic.me/project/ingrid |
repository | https://github.com/intjelic/ingrid |
max_upload_size | |
id | 198183 |
size | 199,456 |
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)