summaryrefslogtreecommitdiffstats
path: root/src/grid.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/grid.rs')
-rw-r--r--src/grid.rs14
1 files changed, 14 insertions, 0 deletions
diff --git a/src/grid.rs b/src/grid.rs
index b84e1b7..f360932 100644
--- a/src/grid.rs
+++ b/src/grid.rs
@@ -110,10 +110,24 @@ impl<T: Default + Clone + Eq + PartialEq> Grid<T> {
Row(self.rows.len())
}
+ pub fn each_row(
+ &self,
+ ) -> impl Iterator<Item = Row> + DoubleEndedIterator + ExactSizeIterator
+ {
+ (0..self.rows().0).map(Row)
+ }
+
pub fn cols(&self) -> Col {
Col(self.rows[0].cells.len())
}
+ pub fn each_col(
+ &self,
+ ) -> impl Iterator<Item = Col> + DoubleEndedIterator + ExactSizeIterator
+ {
+ (0..self.cols().0).map(Col)
+ }
+
pub fn get(&self, row: Row) -> Option<&GridRow<T>> {
self.rows.get(row.0)
}