pub struct Grid<T> { /* private fields */ }Expand description
A width × height grid of T, stored row-major.
Indexing is (x, y): grid[(x, y)] reads the cell at column x,
row y.
Implementations§
Source§impl<T> Grid<T>
impl<T> Grid<T>
Sourcepub fn from_vec(width: usize, height: usize, data: Vec<T>) -> Self
pub fn from_vec(width: usize, height: usize, data: Vec<T>) -> Self
Wraps an existing row-major buffer.
§Panics
Panics if data.len() != width * height or either dimension is 0.
Sourcepub fn idx(&self, x: usize, y: usize) -> usize
pub fn idx(&self, x: usize, y: usize) -> usize
Flat index of (x, y).
Callers holding flat indices (e.g. from Self::as_slice) can map
back with Self::coords.
Sourcepub fn as_mut_slice(&mut self) -> &mut [T]
pub fn as_mut_slice(&mut self) -> &mut [T]
The underlying row-major buffer, mutably.
Trait Implementations§
Source§impl<'a, T> IntoIterator for &'a Grid<T>
impl<'a, T> IntoIterator for &'a Grid<T>
impl<T: PartialEq> StructuralPartialEq for Grid<T>
Auto Trait Implementations§
impl<T> Freeze for Grid<T>
impl<T> RefUnwindSafe for Grid<T>where
Vec<T>: RefUnwindSafe,
impl<T> Send for Grid<T>
impl<T> Sync for Grid<T>
impl<T> Unpin for Grid<T>
impl<T> UnsafeUnpin for Grid<T>where
Vec<T>: UnsafeUnpin,
impl<T> UnwindSafe for Grid<T>where
Vec<T>: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more