pub struct Grid2D<T: Copy + Default> { /* private fields */ }Expand description
A double-buffered 2D grid of cells, stored row-major.
A step reads Self::current and writes Self::next_mut, then Self::swap makes the next
side current.
Implementations§
Source§impl<T: Copy + Default> Grid2D<T>
impl<T: Copy + Default> Grid2D<T>
Sourcepub fn new(width: u32, height: u32) -> Self
pub fn new(width: u32, height: u32) -> Self
Creates a width by height grid with every cell at T::default() on both sides.
Sourcepub fn heap_bytes(&self) -> usize
pub fn heap_bytes(&self) -> usize
Heap memory held by both sides, in bytes.
Sourcepub fn current_mut(&mut self) -> &mut [T]
pub fn current_mut(&mut self) -> &mut [T]
Returns the current side mutably, for initialisation.
A step writes through Self::next_mut.
Sourcepub fn current_and_next_mut(&mut self) -> (&[T], &mut [T])
pub fn current_and_next_mut(&mut self) -> (&[T], &mut [T])
Returns the current side to read and the next side to write, as one split borrow.
Trait Implementations§
Auto Trait Implementations§
impl<T> Freeze for Grid2D<T>
impl<T> RefUnwindSafe for Grid2D<T>where
Vec<T>: RefUnwindSafe,
impl<T> Send for Grid2D<T>
impl<T> Sync for Grid2D<T>
impl<T> Unpin for Grid2D<T>
impl<T> UnsafeUnpin for Grid2D<T>where
Vec<T>: UnsafeUnpin,
impl<T> UnwindSafe for Grid2D<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