pub struct Block<'a, T, B: BlockDim> { /* private fields */ }Expand description
A view of a 2D block contiguous in memory.
Can be obtained via BlockIter, which is created by calling BlockGrid::block_iter.
Implementations§
Source§impl<'a, T, B: BlockDim> Block<'a, T, B>
impl<'a, T, B: BlockDim> Block<'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 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 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.
Trait Implementations§
impl<'a, T: Copy, B: Copy + BlockDim> Copy for Block<'a, T, B>
Auto Trait Implementations§
impl<'a, T, B> Freeze for Block<'a, T, B>
impl<'a, T, B> RefUnwindSafe for Block<'a, T, B>where
B: RefUnwindSafe,
T: RefUnwindSafe,
impl<'a, T, B> Send for Block<'a, T, B>
impl<'a, T, B> Sync for Block<'a, T, B>
impl<'a, T, B> Unpin for Block<'a, T, B>where
B: Unpin,
impl<'a, T, B> UnwindSafe for Block<'a, T, B>where
B: UnwindSafe,
T: RefUnwindSafe,
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