pub struct BlockMut<'a, T, B: BlockDim> { /* private fields */ }Expand description
A mutable view of a 2D block contiguous in memory.
Can be obtained via BlockIterMut, which is created by calling BlockGrid::block_iter_mut.
Implementations§
Source§impl<'a, T, B: BlockDim> BlockMut<'a, T, B>
impl<'a, T, B: BlockDim> BlockMut<'a, T, B>
Sourcepub fn coords(&self) -> Coords
pub fn coords(&self) -> Coords
Returns the coordinates of the entire block.
Block coordinates mean that the (i, j) refers to the i-th row of blocks and the
j-th block in that row. If you need the coordinates of the first (top-left) element,
use starts_at instead.
Sourcepub fn starts_at(&self) -> Coords
pub fn starts_at(&self) -> Coords
Returns of the coordinates of the first (top-left) element in the block.
Sourcepub fn contains(&self, (row, col): Coords) -> bool
pub fn contains(&self, (row, col): Coords) -> bool
Returns true if the given coordinates are valid.
Sourcepub fn get(&self, coords: Coords) -> Option<&T>
pub fn get(&self, coords: Coords) -> Option<&T>
Returns a reference to the element at the given coordinates, or None if they are
out-of-bounds.
Sourcepub fn get_mut(&mut self, coords: Coords) -> Option<&mut T>
pub fn get_mut(&mut self, coords: Coords) -> Option<&mut T>
Returns a mutable reference to the element at the given coordinates, or None if they
are out-of-bounds.
Sourcepub unsafe fn get_unchecked(&self, coords: Coords) -> &T
pub unsafe fn get_unchecked(&self, coords: Coords) -> &T
Returns a reference to the element at the given coordinates, without bounds checking.
§Safety
Calling this method with out-of-bounds coordinates is undefined-behaviour.
Sourcepub unsafe fn get_unchecked_mut(&mut self, coords: Coords) -> &mut T
pub unsafe fn get_unchecked_mut(&mut self, coords: Coords) -> &mut T
Returns a mutable reference to the element at the given coordinates, without bounds checking.
§Safety
Calling this method with out-of-bounds coordinates is undefined-behaviour.