equal
deleted
inserted
replaced
1 use integral_geometry::Size; |
1 use integral_geometry::Size; |
2 use std::{ |
2 use std::{ |
3 ops::{Index, IndexMut}, |
3 ops::{Index, IndexMut}, |
4 slice::SliceIndex, |
4 slice::{ChunksExact, ChunksExactMut, SliceIndex}, |
5 }; |
5 }; |
6 |
6 |
7 #[derive(Debug, Clone)] |
7 #[derive(Debug, Clone)] |
8 pub struct Vec2D<T> { |
8 pub struct Vec2D<T> { |
9 data: Vec<T>, |
9 data: Vec<T>, |
112 self.data |
112 self.data |
113 .get_unchecked_mut(row * self.size.width as usize + column) |
113 .get_unchecked_mut(row * self.size.width as usize + column) |
114 } |
114 } |
115 |
115 |
116 #[inline] |
116 #[inline] |
117 pub fn rows(&self) -> impl DoubleEndedIterator<Item = &[T]> { |
117 pub fn rows(&self) -> ChunksExact<'_, T> { |
118 self.data.chunks_exact(self.width()) |
118 self.data.chunks_exact(self.width()) |
119 } |
119 } |
120 |
120 |
121 #[inline] |
121 #[inline] |
122 pub fn rows_mut(&mut self) -> impl DoubleEndedIterator<Item = &mut [T]> { |
122 pub fn rows_mut(&mut self) -> ChunksExactMut<'_, T> { |
123 let width = self.width(); |
123 let width = self.width(); |
124 self.data.chunks_exact_mut(width) |
124 self.data.chunks_exact_mut(width) |
125 } |
125 } |
126 |
126 |
127 #[inline] |
127 #[inline] |