pub struct Inner<T, D> { /* private fields */ }Expand description
A helper type that abstracts over owned and borrowed buffers.
The types Buf2, Slice2, and MutSlice2 deref to Inner.
Implementations§
Source§impl<T, D> Inner<T, D>
impl<T, D> Inner<T, D>
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.
Source§impl<T, D: Deref<Target = [T]>> Inner<T, D>
impl<T, D: Deref<Target = [T]>> Inner<T, D>
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().
Source§impl<T, D: DerefMut<Target = [T]>> Inner<T, D>
impl<T, D: DerefMut<Target = [T]>> Inner<T, D>
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.