Crate grid_iter

Crate grid_iter 

Source
Expand description

Grids for Iterators

Provides a two dimensional abstraction over Iterators. Intended to be simple, flexible and ideomatic.

use grid_iter::IntoGridIter;

let file:&str = "1,2,3,4,5\n6,7,8,9,10\n11,12,13,14,15";
let columns = file.find('\n').unwrap();
let mut store = file.lines()
    .flat_map(|line|line.split(',').map(|s|s.parse().unwrap()))
    .collect::<Vec<_>>();
store.iter_mut().into_grid_iter(columns).iter_col(3).for_each(|i| *i= 0);
store.iter_mut().into_grid_iter(columns).iter_row(1).for_each(|i| *i+= 1);
let borrowing_grid = store.iter().into_grid_iter(5);
drop(borrowing_grid);
let capturing_grid = store.iter().into_grid_iter(5);
println!("{:?}", capturing_grid);

Structs§

GridIter
The Grid struct wraps an Iterator and provies two dimensional access over its contents.

Traits§

IntoGridIter
IntoGridIter ist implemented for all iterators. Provides the grid function to wrap iterators with the Grid struct which contains the main functionality.

Type Aliases§

ColIter
DiagBwdIter
DiagFwdIter
Get
RowIter