BlockMut

Struct BlockMut 

Source
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>

Source

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.

Source

pub fn starts_at(&self) -> Coords

Returns of the coordinates of the first (top-left) element in the block.

Source

pub fn contains(&self, (row, col): Coords) -> bool

Returns true if the given coordinates are valid.

Source

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.

Source

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.

Source

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.

Source

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.

Source

pub fn raw(&self) -> &[T]

Returns all elements in block as a slice in memory order.

Source

pub fn raw_mut(&mut self) -> &mut [T]

Returns all elements in block as a mutable slice in memory order.

Trait Implementations§

Source§

impl<'a, T: Debug, B: Debug + BlockDim> Debug for BlockMut<'a, T, B>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'a, T, B: BlockDim> Index<(usize, usize)> for BlockMut<'a, T, B>

Source§

type Output = T

The returned type after indexing.
Source§

fn index(&self, coords: Coords) -> &Self::Output

Performs the indexing (container[index]) operation. Read more
Source§

impl<'a, T, B: BlockDim> IndexMut<(usize, usize)> for BlockMut<'a, T, B>

Source§

fn index_mut(&mut self, coords: Coords) -> &mut Self::Output

Performs the mutable indexing (container[index]) operation. Read more

Auto Trait Implementations§

§

impl<'a, T, B> Freeze for BlockMut<'a, T, B>

§

impl<'a, T, B> RefUnwindSafe for BlockMut<'a, T, B>

§

impl<'a, T, B> Send for BlockMut<'a, T, B>
where B: Send, T: Send,

§

impl<'a, T, B> Sync for BlockMut<'a, T, B>
where B: Sync, T: Sync,

§

impl<'a, T, B> Unpin for BlockMut<'a, T, B>
where B: Unpin,

§

impl<'a, T, B> !UnwindSafe for BlockMut<'a, T, B>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.