pub struct MutSlice2<'a, T>(/* private fields */);Expand description
A mutable rectangular view to a region of a Buf2, a Slice2,
or in general any &[T] slice of memory.
Implementations§
Methods from Deref<Target = Inner<T, &'a mut [T]>>§
Sourcepub fn is_contiguous(&self) -> bool
pub fn is_contiguous(&self) -> bool
Returns whether the rows of self are stored as one contiguous
slice, without gaps between rows.
Buf2 instances are always contiguous. A Slice2 or MutSlice2
instance is contiguous if its width equals its stride, if its
height is 1, or if it is empty.
Sourcepub fn slice(&self, rect: impl Into<Rect>) -> Slice2<'_, T>
pub fn slice(&self, rect: impl Into<Rect>) -> Slice2<'_, T>
Returns a borrowed rectangular slice of self.
§Panics
If any part of rect is outside the bounds of self.
Sourcepub fn get(&self, pos: impl Into<Point2u>) -> Option<&T>
pub fn get(&self, pos: impl Into<Point2u>) -> Option<&T>
Returns a reference to the element at pos,
or None if pos is out of bounds.
Sourcepub fn rows(&self) -> impl Iterator<Item = &[T]>
pub fn rows(&self) -> impl Iterator<Item = &[T]>
Returns an iterator over the rows of self as &[T] slices.
The length of each slice equals self.width().
Sourcepub fn iter(&self) -> impl Iterator<Item = &T>
pub fn iter(&self) -> impl Iterator<Item = &T>
Returns an iterator over the elements of self in row-major order.
First returns the elements on row 0 from left to right, followed by the elements on row 1, and so on.
Sourcepub fn as_mut_slice2(&mut self) -> MutSlice2<'_, T>
pub fn as_mut_slice2(&mut self) -> MutSlice2<'_, T>
Returns a mutably borrowed rectangular slice of self.
Sourcepub fn rows_mut(&mut self) -> impl Iterator<Item = &mut [T]>
pub fn rows_mut(&mut self) -> impl Iterator<Item = &mut [T]>
Returns an iterator over the rows of this buffer as &mut [T].
The length of each slice equals self.width().
Sourcepub fn iter_mut(&mut self) -> impl Iterator<Item = &mut T>
pub fn iter_mut(&mut self) -> impl Iterator<Item = &mut T>
Returns a mutable iterator over all the elements of self,
yielded in row-major order.
Sourcepub fn fill_with<F>(&mut self, fill_fn: F)
pub fn fill_with<F>(&mut self, fill_fn: F)
Fills self by calling a function for each element.
Calls f(x, y) for every element, where x and y are the column
and row indices of the element. Proceeds in row-major order.
Sourcepub fn copy_from(&mut self, other: impl AsSlice2<T>)where
T: Copy,
pub fn copy_from(&mut self, other: impl AsSlice2<T>)where
T: Copy,
Copies each element in other to the same position in self.
This operation is often called “blitting”.
§Panics
if the dimensions of self and other do not match.
Trait Implementations§
Source§impl<T> AsMutSlice2<T> for MutSlice2<'_, T>
impl<T> AsMutSlice2<T> for MutSlice2<'_, T>
Source§fn as_mut_slice2(&mut self) -> MutSlice2<'_, T>
fn as_mut_slice2(&mut self) -> MutSlice2<'_, T>
MutSlice2 view of Self.