pub struct Layout<T> { /* private fields */ }Expand description
The layout for Strided.
This struct ensures that the Self::cstride is greater than or equal to Self::ncols
and that the addressable span is valid for elements of type T. In particular, the
linear length does not overflow usize::MAX and its size in bytes does not exceed
isize::MAX.
The linear length of Strided is given by the formula
self.nrows.saturating_sub(1) * self.cstride + self.nrows.min(1) * self.ncolsThis allows the last row to occupy less than a full stride.
Implementations§
Source§impl<T> Layout<T>
impl<T> Layout<T>
Sourcepub fn new(
nrows: usize,
ncols: usize,
cstride: usize,
) -> Result<Self, LayoutError>
pub fn new( nrows: usize, ncols: usize, cstride: usize, ) -> Result<Self, LayoutError>
Construct a new Layout.
Errors if:
cstride < ncols.- The computation of the linear length overflows
usize::MAX. - The number of bytes required for the full span exceeds
isize::MAX.
Sourcepub fn linear_length(&self) -> usize
pub fn linear_length(&self) -> usize
Return the length of the addressable span described by this Layout, including
gaps between rows.
Trait Implementations§
impl<T> Copy for Layout<T>
Auto Trait Implementations§
impl<T> Freeze for Layout<T>
impl<T> RefUnwindSafe for Layout<T>
impl<T> Send for Layout<T>
impl<T> Sync for Layout<T>
impl<T> Unpin for Layout<T>
impl<T> UnsafeUnpin for Layout<T>
impl<T> UnwindSafe for Layout<T>
Blanket Implementations§
impl<T> AsyncFriendly for T
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more