utils fixes
This commit is contained in:
2 files changed
+18
-1
No files matched your search
@@ -139,6 +139,23 @@ impl<'a, T> Iterator for GridRowIter<'a, T> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(Debug)]
|
||||||
|
pub struct CoordIter<'a, T> {
|
||||||
|
pos: usize,
|
||||||
|
grid: &'a Grid<T>,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl<'a, T: Clone + Eq + PartialEq + Debug> Iterator for CoordIter<'a, T> {
|
||||||
|
type Item = Coord2d;
|
||||||
|
fn next(&mut self) -> Option<Self::Item> {
|
||||||
|
if self.pos < self.grid.data.len() {
|
||||||
|
self.grid.coord(self.pos as i64).into()
|
||||||
|
} else {
|
||||||
|
None
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub struct GridColIter<'a, T> {
|
pub struct GridColIter<'a, T> {
|
||||||
grid: &'a Grid<T>,
|
grid: &'a Grid<T>,
|
||||||
|
|||||||
@@ -92,7 +92,7 @@ mod tests {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn it_works() {
|
fn it_works() {
|
||||||
let result = add(2, 2);
|
let result = 2.add(2);
|
||||||
assert_eq!(result, 4);
|
assert_eq!(result, 4);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Reference in new issue
Block a user