pub struct Array2d<T, const C: usize, const R: usize, const CR: usize, const RMAJ: bool = true, S: Storage = Bare> { /* private fields */ }
Expand description
A static 2-dimensional Array
.
It is generic in respect to its:
- elements (
T
), - number of columns (
C
), - number of rows (
R
), - total capacity (
CR
), - storage order (
RMAJ
) - storage abstraction (
S
).
The total lenght CR
must be equal to the product C
* R
.
The
storage order
is row-major by default (RMAJ = true
). It can be column-major if set to false.
§Methods
- Construct:
with_cloned
,with_copied
. - Deconstruct:
as_slice
,as_mut_slice
,into_array
(const
),into_slice
(alloc
),into_vec
(alloc
). - Query:
[
len
][Self::len] [x_len
][Self::x_len] [y_len
][Self::y_len] [is_empty
][Self::is_empty],contains
. - Indexing and coordinates (for the current order):
- Indexing and coordinates (specific for the opposite order):
- row-major:
get_ref_cmaj
(uc
),get_mut_cmaj
(uc
),set_cmaj
(uc
),get_index_cmaj
(uc
),get_coords_cmaj
(uc
). - column-major:
get_ref_rmaj
(uc
),get_mut_rmaj
(uc
),set_rmaj
(uc
),get_index_rmaj
(uc
),get_coords_rmaj
(uc
).
- row-major:
§Panics
Note that the Default
and ConstDefault
constructors will panic if C * R != CR
.
Implementations§
Source§impl<T: Clone, const C: usize, const R: usize, const CR: usize, const RMAJ: bool> Array2d<T, C, R, CR, RMAJ, Bare>
impl<T: Clone, const C: usize, const R: usize, const CR: usize, const RMAJ: bool> Array2d<T, C, R, CR, RMAJ, Bare>
Sourcepub fn with_cloned(element: T) -> Result<Self, MismatchedBounds> ⓘ
pub fn with_cloned(element: T) -> Result<Self, MismatchedBounds> ⓘ
Returns a 2-dimensional grid, allocated in the stack,
using element
to fill the remaining free data.
§Errors
Returns IndexOutOfBounds
if C * R > usize::MAX
or MismatchedCapacity
if C * R != CR
.
§Examples
let g = Array2d::<_, 4, 4, {4 * 4}>::with_cloned('.');
Source§impl<T: Copy, const C: usize, const R: usize, const CR: usize, const RMAJ: bool> Array2d<T, C, R, CR, RMAJ, Bare>
impl<T: Copy, const C: usize, const R: usize, const CR: usize, const RMAJ: bool> Array2d<T, C, R, CR, RMAJ, Bare>
Sourcepub const fn with_copied(element: T) -> Result<Self, MismatchedBounds> ⓘ
pub const fn with_copied(element: T) -> Result<Self, MismatchedBounds> ⓘ
Returns a 2-dimensional grid, allocated in the stack,
using element
to fill the remaining free data.
§Errors
Returns IndexOutOfBounds
if C * R > usize::MAX
or MismatchedCapacity
if C * R != CR
.
§Examples
const GRID: Result<Array2d::<char, 4, 4, {4 * 4}>, MismatchedBounds>
= Array2d::with_copied('.');
assert![GRID.is_ok()];
Source§impl<T: Clone, const C: usize, const R: usize, const CR: usize, const RMAJ: bool> Array2d<T, C, R, CR, RMAJ, Boxed>
impl<T: Clone, const C: usize, const R: usize, const CR: usize, const RMAJ: bool> Array2d<T, C, R, CR, RMAJ, Boxed>
Sourcepub fn with_cloned(element: T) -> Result<Self, MismatchedBounds> ⓘ
Available on crate feature alloc
only.
pub fn with_cloned(element: T) -> Result<Self, MismatchedBounds> ⓘ
alloc
only.Returns a 2-dimensional grid, allocated in the heap,
using element
to fill the remaining free data.
§Errors
Returns IndexOutOfBounds
if C * R > usize::MAX
or MismatchedCapacity
if C * R != CR
.
§Examples
let g = Array2d::<_, 4, 4, {4 * 4}, true, Boxed>::with_cloned(String::from("·"));
Source§impl<T, const C: usize, const R: usize, const CR: usize, const RMAJ: bool, S: Storage> Array2d<T, C, R, CR, RMAJ, S>
impl<T, const C: usize, const R: usize, const CR: usize, const RMAJ: bool, S: Storage> Array2d<T, C, R, CR, RMAJ, S>
Sourcepub const fn capacity(&self) -> usize ⓘ
pub const fn capacity(&self) -> usize ⓘ
Returns the total capacity of the array, equals CR == C * R
.
Sourcepub const fn cap_col(&self) -> usize ⓘ
pub const fn cap_col(&self) -> usize ⓘ
Returns the capacity of a column, equivalent to num_rows
== R
.
Sourcepub const fn cap_row(&self) -> usize ⓘ
pub const fn cap_row(&self) -> usize ⓘ
Returns the capacity of a row, equivalent to num_cols
== C
.
Sourcepub const fn num_cols(&self) -> usize ⓘ
pub const fn num_cols(&self) -> usize ⓘ
Returns the number of columns, equivalent to cap_row
== C
.
Sourcepub const fn num_rows(&self) -> usize ⓘ
pub const fn num_rows(&self) -> usize ⓘ
Returns the number of rows, equivalent to cap_col
== R
.
Sourcepub fn as_mut_slice(&mut self) -> &mut [T] ⓘ
pub fn as_mut_slice(&mut self) -> &mut [T] ⓘ
Returns the stack as an exclusive slice.
Source§impl<T, const C: usize, const R: usize, const CR: usize, S: Storage> Array2d<T, C, R, CR, true, S>
impl<T, const C: usize, const R: usize, const CR: usize, S: Storage> Array2d<T, C, R, CR, true, S>
Sourcepub const fn cap_major(&self) -> usize ⓘ
pub const fn cap_major(&self) -> usize ⓘ
Returns the capacity per item in the major dimension based on layout (RMAJ
).
For row-major, this is the number of columns. For column-major, this is the number of rows.
Sourcepub const fn cap_minor(&self) -> usize ⓘ
pub const fn cap_minor(&self) -> usize ⓘ
Returns the capacity per item in the minor dimension based on layout (RMAJ
).
For row-major, this is the number of rows. For column-major, this is the number of columns.
Source§impl<T, const C: usize, const R: usize, const CR: usize, S: Storage> Array2d<T, C, R, CR, false, S>
impl<T, const C: usize, const R: usize, const CR: usize, S: Storage> Array2d<T, C, R, CR, false, S>
Sourcepub const fn cap_major(&self) -> usize ⓘ
pub const fn cap_major(&self) -> usize ⓘ
Returns the capacity per item in the major dimension based on layout (RMAJ
).
For row-major, this is the number of columns. For column-major, this is the number of rows.
Sourcepub const fn cap_minor(&self) -> usize ⓘ
pub const fn cap_minor(&self) -> usize ⓘ
Returns the capacity per item in the minor dimension based on layout (RMAJ
).
For row-major, this is the number of rows. For column-major, this is the number of columns.
Source§impl<T, const C: usize, const R: usize, const CR: usize, const RMAJ: bool> Array2d<T, C, R, CR, RMAJ, Bare>
impl<T, const C: usize, const R: usize, const CR: usize, const RMAJ: bool> Array2d<T, C, R, CR, RMAJ, Bare>
Sourcepub fn into_array(self) -> [T; CR]
pub fn into_array(self) -> [T; CR]
Returns the inner BareBox
ed primitive array.
Source§impl<T: Copy, const C: usize, const R: usize, const CR: usize, const RMAJ: bool> Array2d<T, C, R, CR, RMAJ, Bare>
impl<T: Copy, const C: usize, const R: usize, const CR: usize, const RMAJ: bool> Array2d<T, C, R, CR, RMAJ, Bare>
Sourcepub const fn into_array_copy(self) -> [T; CR]
pub const fn into_array_copy(self) -> [T; CR]
Returns the inner BareBox
ed primitive array in compile-time.
Source§impl<T, const C: usize, const R: usize, const CR: usize, const RMAJ: bool> Array2d<T, C, R, CR, RMAJ, Boxed>
impl<T, const C: usize, const R: usize, const CR: usize, const RMAJ: bool> Array2d<T, C, R, CR, RMAJ, Boxed>
Sourcepub fn into_array(self) -> Box<[T; CR]>
Available on crate feature alloc
only.
pub fn into_array(self) -> Box<[T; CR]>
alloc
only.Returns the inner Box
ed primitive array.
Sourcepub fn into_slice(self) -> Box<[T]>
Available on crate feature alloc
only.
pub fn into_slice(self) -> Box<[T]>
alloc
only.Returns the inner Box
ed primitive array as a slice.
Source§impl<T: Clone, const C: usize, const R: usize, const CR: usize, const RMAJ: bool, S: Storage> Array2d<T, C, R, CR, RMAJ, S>
impl<T: Clone, const C: usize, const R: usize, const CR: usize, const RMAJ: bool, S: Storage> Array2d<T, C, R, CR, RMAJ, S>
Source§impl<T: PartialEq, const C: usize, const R: usize, const CR: usize, const RMAJ: bool, S: Storage> Array2d<T, C, R, CR, RMAJ, S>
impl<T: PartialEq, const C: usize, const R: usize, const CR: usize, const RMAJ: bool, S: Storage> Array2d<T, C, R, CR, RMAJ, S>
Source§impl<T, const C: usize, const R: usize, const CR: usize, S: Storage> Array2d<T, C, R, CR, true, S>
§Single element indexing (row-major order)
impl<T, const C: usize, const R: usize, const CR: usize, S: Storage> Array2d<T, C, R, CR, true, S>
§Single element indexing (row-major order)
Sourcepub fn get_ref(&self, col_row: [usize; 2]) -> Result<&T, IndexOutOfBounds> ⓘ
pub fn get_ref(&self, col_row: [usize; 2]) -> Result<&T, IndexOutOfBounds> ⓘ
Returns a reference to the element at the given 2D coordinates in the current row-major order.
§Errors
Returns IndexOutOfBounds
if the coordinates are out of bounds.
Sourcepub fn get_ref_unchecked(&self, col_row: [usize; 2]) -> &T
pub fn get_ref_unchecked(&self, col_row: [usize; 2]) -> &T
Returns a reference to the element at the given 2D coordinates in the current row-major order.
§Panics
Panics if the coordinates are out of bounds.
Sourcepub fn get_mut(
&mut self,
col_row: [usize; 2],
) -> Result<&mut T, IndexOutOfBounds> ⓘ
pub fn get_mut( &mut self, col_row: [usize; 2], ) -> Result<&mut T, IndexOutOfBounds> ⓘ
Returns an exclusive reference to the element at the given 2D coordinates in the current row-major order.
§Errors
Returns IndexOutOfBounds
if the coordinates are out of bounds.
Sourcepub fn get_mut_unchecked(&mut self, col_row: [usize; 2]) -> &mut T
pub fn get_mut_unchecked(&mut self, col_row: [usize; 2]) -> &mut T
Returns an exclusive reference to the element at the given 2D coordinates in the current row-major order.
§Panics
Panics if the coordinates are out of bounds.
Sourcepub fn set(
&mut self,
element: T,
col_row: [usize; 2],
) -> Result<(), IndexOutOfBounds> ⓘ
pub fn set( &mut self, element: T, col_row: [usize; 2], ) -> Result<(), IndexOutOfBounds> ⓘ
Sets the element at the given 2D coordinates in the current row-major order.
§Errors
Returns IndexOutOfBounds
if the coordinates are out of bounds.
Sourcepub fn set_unchecked(&mut self, element: T, col_row: [usize; 2])
pub fn set_unchecked(&mut self, element: T, col_row: [usize; 2])
Sets the element at the given 2D coordinates in the current row-major order.
§Panics
Panics if the coordinates are out of bounds.
Source§impl<T: Clone, const C: usize, const R: usize, const CR: usize, S: Storage> Array2d<T, C, R, CR, true, S>
impl<T: Clone, const C: usize, const R: usize, const CR: usize, S: Storage> Array2d<T, C, R, CR, true, S>
Sourcepub fn get(&self, col_row: [usize; 2]) -> Result<T, IndexOutOfBounds> ⓘ
pub fn get(&self, col_row: [usize; 2]) -> Result<T, IndexOutOfBounds> ⓘ
Returns a clone of the element at the given 2D coordinates in the current row-major order.
§Errors
Returns IndexOutOfBounds
if the coordinates are out of bounds.
Sourcepub fn get_unchecked(&self, col_row: [usize; 2]) -> T
pub fn get_unchecked(&self, col_row: [usize; 2]) -> T
Returns a clone of the element at the given 2D coordinates in the current row-major order.
§Panics
Panics if the coordinates are out of bounds.
Source§impl<T, const C: usize, const R: usize, const CR: usize, S: Storage> Array2d<T, C, R, CR, true, S>
§Single element indexing (using opposite column-major order)
impl<T, const C: usize, const R: usize, const CR: usize, S: Storage> Array2d<T, C, R, CR, true, S>
§Single element indexing (using opposite column-major order)
Sourcepub fn get_ref_cmaj(&self, col_row: [usize; 2]) -> Result<&T, IndexOutOfBounds> ⓘ
pub fn get_ref_cmaj(&self, col_row: [usize; 2]) -> Result<&T, IndexOutOfBounds> ⓘ
Returns a reference to the element at the given 2D coordinates in the opposite column-major order.
§Errors
Returns IndexOutOfBounds
if the coordinates are out of bounds.
Sourcepub fn get_ref_cmaj_unchecked(&self, col_row: [usize; 2]) -> &T
pub fn get_ref_cmaj_unchecked(&self, col_row: [usize; 2]) -> &T
Returns a reference to the element at the given 2D coordinates in the opposite column-major order.
§Panics
Panics if the coordinates are out of bounds.
Sourcepub fn get_mut_cmaj(
&mut self,
col_row: [usize; 2],
) -> Result<&mut T, IndexOutOfBounds> ⓘ
pub fn get_mut_cmaj( &mut self, col_row: [usize; 2], ) -> Result<&mut T, IndexOutOfBounds> ⓘ
Returns an exclusive reference to the element at the given 2D coordinates in the opposite column-major order.
§Errors
Returns IndexOutOfBounds
if the coordinates are out of bounds.
Sourcepub fn get_mut_cmaj_unchecked(&mut self, col_row: [usize; 2]) -> &mut T
pub fn get_mut_cmaj_unchecked(&mut self, col_row: [usize; 2]) -> &mut T
Returns an exclusive reference to the element at the given 2D coordinates in the opposite column-major order.
§Panics
Panics if the coordinates are out of bounds.
Sourcepub fn set_cmaj(
&mut self,
element: T,
col_row: [usize; 2],
) -> Result<(), IndexOutOfBounds> ⓘ
pub fn set_cmaj( &mut self, element: T, col_row: [usize; 2], ) -> Result<(), IndexOutOfBounds> ⓘ
Sets the element at the given 2D coordinates in the opposite column-major order.
§Errors
Returns IndexOutOfBounds
if the coordinates are out of bounds.
Sourcepub fn set_cmaj_unchecked(&mut self, element: T, col_row: [usize; 2])
pub fn set_cmaj_unchecked(&mut self, element: T, col_row: [usize; 2])
Sets the element at the given 2D coordinates in the opposite column-major order.
§Panics
Panics if the coordinates are out of bounds.
Sourcepub const fn get_index_cmaj(
col_row: [usize; 2],
) -> Result<usize, IndexOutOfBounds> ⓘ
pub const fn get_index_cmaj( col_row: [usize; 2], ) -> Result<usize, IndexOutOfBounds> ⓘ
Calculates the 1D array index from the given 2D coordinates in the opposite column-major order.
§Errors
Returns IndexOutOfBounds
if the resulting index is > CR
.
Sourcepub const fn get_index_cmaj_unchecked(col_row: [usize; 2]) -> usize ⓘ
pub const fn get_index_cmaj_unchecked(col_row: [usize; 2]) -> usize ⓘ
Calculates the 1D array index from the given 2D coordinates in the opposite column-major order.
Sourcepub const fn get_coords_cmaj(
index: usize,
) -> Result<[usize; 2], IndexOutOfBounds> ⓘ
pub const fn get_coords_cmaj( index: usize, ) -> Result<[usize; 2], IndexOutOfBounds> ⓘ
Calculates the 2D coordinates from the given 1D array index in the opposite column-major order.
§Errors
Returns IndexOutOfBounds
if index
is > CR
.
Sourcepub const fn get_coords_cmaj_unchecked(index: usize) -> [usize; 2]
pub const fn get_coords_cmaj_unchecked(index: usize) -> [usize; 2]
Calculates the 2D coordinates from the given 1D array index in the opposite column-major order.
Source§impl<T: Clone, const C: usize, const R: usize, const CR: usize, S: Storage> Array2d<T, C, R, CR, true, S>
impl<T: Clone, const C: usize, const R: usize, const CR: usize, S: Storage> Array2d<T, C, R, CR, true, S>
Sourcepub fn get_cmaj(&self, col_row: [usize; 2]) -> Result<T, IndexOutOfBounds> ⓘ
pub fn get_cmaj(&self, col_row: [usize; 2]) -> Result<T, IndexOutOfBounds> ⓘ
Returns a clone of the element at the given 2D coordinates in the opposite column-major order.
§Errors
Returns IndexOutOfBounds
if the coordinates are out of bounds.
Sourcepub fn get_cmaj_unchecked(&self, col_row: [usize; 2]) -> T
pub fn get_cmaj_unchecked(&self, col_row: [usize; 2]) -> T
Returns a clone of the element at the given 2D coordinates in the opposite column-major order.
§Panics
Panics if the coordinates are out of bounds.
Source§impl<T, const C: usize, const R: usize, const CR: usize, S: Storage> Array2d<T, C, R, CR, false, S>
§Single element indexing (column-major order)
impl<T, const C: usize, const R: usize, const CR: usize, S: Storage> Array2d<T, C, R, CR, false, S>
§Single element indexing (column-major order)
Sourcepub fn get_ref(&self, col_row: [usize; 2]) -> Result<&T, IndexOutOfBounds> ⓘ
pub fn get_ref(&self, col_row: [usize; 2]) -> Result<&T, IndexOutOfBounds> ⓘ
Returns a reference to the element at the given 2D coordinates in the current column-major order.
§Errors
Returns IndexOutOfBounds
if the coordinates are out of bounds.
Sourcepub fn get_ref_unchecked(&self, col_row: [usize; 2]) -> &T
pub fn get_ref_unchecked(&self, col_row: [usize; 2]) -> &T
Returns a reference to the element at the given 2D coordinates in the current column-major order.
§Panics
Panics if the coordinates are out of bounds.
Sourcepub fn get_mut(
&mut self,
col_row: [usize; 2],
) -> Result<&mut T, IndexOutOfBounds> ⓘ
pub fn get_mut( &mut self, col_row: [usize; 2], ) -> Result<&mut T, IndexOutOfBounds> ⓘ
Returns an exclusive reference to the element at the given 2D coordinates in the current column-major order.
§Errors
Returns IndexOutOfBounds
if the coordinates are out of bounds.
Sourcepub fn get_mut_unchecked(&mut self, col_row: [usize; 2]) -> &mut T
pub fn get_mut_unchecked(&mut self, col_row: [usize; 2]) -> &mut T
Returns an exclusive reference to the element at the given 2D coordinates in the current column-major order.
§Panics
Panics if the coordinates are out of bounds.
Sourcepub fn set(
&mut self,
element: T,
col_row: [usize; 2],
) -> Result<(), IndexOutOfBounds> ⓘ
pub fn set( &mut self, element: T, col_row: [usize; 2], ) -> Result<(), IndexOutOfBounds> ⓘ
Sets the element at the given 2D coordinates in the current column-major order.
§Errors
Returns IndexOutOfBounds
if the coordinates are out of bounds.
Sourcepub fn set_unchecked(&mut self, element: T, col_row: [usize; 2])
pub fn set_unchecked(&mut self, element: T, col_row: [usize; 2])
Sets the element at the given 2D coordinates in the current column-major order.
§Panics
Panics if the coordinates are out of bounds.
Source§impl<T: Clone, const C: usize, const R: usize, const CR: usize, S: Storage> Array2d<T, C, R, CR, false, S>
impl<T: Clone, const C: usize, const R: usize, const CR: usize, S: Storage> Array2d<T, C, R, CR, false, S>
Sourcepub fn get(&self, col_row: [usize; 2]) -> Result<T, IndexOutOfBounds> ⓘ
pub fn get(&self, col_row: [usize; 2]) -> Result<T, IndexOutOfBounds> ⓘ
Returns a clone of the element at the given 2D coordinates in the current column-major order.
§Errors
Returns IndexOutOfBounds
if the coordinates are out of bounds.
Sourcepub fn get_unchecked(&self, col_row: [usize; 2]) -> T
pub fn get_unchecked(&self, col_row: [usize; 2]) -> T
Returns a clone of the element at the given 2D coordinates in the current column-major order.
§Panics
Panics if the coordinates are out of bounds.
Source§impl<T, const C: usize, const R: usize, const CR: usize, S: Storage> Array2d<T, C, R, CR, false, S>
§Single element indexing (using opposite row-major order)
impl<T, const C: usize, const R: usize, const CR: usize, S: Storage> Array2d<T, C, R, CR, false, S>
§Single element indexing (using opposite row-major order)
Sourcepub fn get_ref_rmaj(&self, col_row: [usize; 2]) -> Result<&T, IndexOutOfBounds> ⓘ
pub fn get_ref_rmaj(&self, col_row: [usize; 2]) -> Result<&T, IndexOutOfBounds> ⓘ
Returns a reference to the element at the given 2D coordinates in the opposite row-major order.
§Errors
Returns IndexOutOfBounds
if the coordinates are out of bounds.
Sourcepub fn get_ref_rmaj_unchecked(&self, col_row: [usize; 2]) -> &T
pub fn get_ref_rmaj_unchecked(&self, col_row: [usize; 2]) -> &T
Returns a reference to the element at the given 2D coordinates in the opposite row-major order.
§Panics
Panics if the coordinates are out of bounds.
Sourcepub fn get_mut_rmaj(
&mut self,
col_row: [usize; 2],
) -> Result<&mut T, IndexOutOfBounds> ⓘ
pub fn get_mut_rmaj( &mut self, col_row: [usize; 2], ) -> Result<&mut T, IndexOutOfBounds> ⓘ
Returns an exclusive reference to the element at the given 2D coordinates in the opposite row-major order.
§Errors
Returns IndexOutOfBounds
if the coordinates are out of bounds.
Sourcepub fn get_mut_rmaj_unchecked(&mut self, col_row: [usize; 2]) -> &mut T
pub fn get_mut_rmaj_unchecked(&mut self, col_row: [usize; 2]) -> &mut T
Returns an exclusive reference to the element at the given 2D coordinates in the opposite row-major order.
§Panics
Panics if the coordinates are out of bounds.
Sourcepub fn set_rmaj(
&mut self,
element: T,
col_row: [usize; 2],
) -> Result<(), IndexOutOfBounds> ⓘ
pub fn set_rmaj( &mut self, element: T, col_row: [usize; 2], ) -> Result<(), IndexOutOfBounds> ⓘ
Sets the element at the given 2D coordinates in the opposite row-major order.
§Errors
Returns IndexOutOfBounds
if the coordinates are out of bounds.
Sourcepub fn set_rmaj_unchecked(&mut self, element: T, col_row: [usize; 2])
pub fn set_rmaj_unchecked(&mut self, element: T, col_row: [usize; 2])
Sets the element at the given 2D coordinates in the opposite row-major order.
§Panics
Panics if the coordinates are out of bounds.
Sourcepub const fn get_index_rmaj(
col_row: [usize; 2],
) -> Result<usize, IndexOutOfBounds> ⓘ
pub const fn get_index_rmaj( col_row: [usize; 2], ) -> Result<usize, IndexOutOfBounds> ⓘ
Calculates the 1D array index from the given 2D coordinates in the opposite row-major order.
§Errors
Returns IndexOutOfBounds
if the resulting index is > CR
.
Sourcepub const fn get_index_rmaj_unchecked(col_row: [usize; 2]) -> usize ⓘ
pub const fn get_index_rmaj_unchecked(col_row: [usize; 2]) -> usize ⓘ
Calculates the 1D array index from the given 2D coordinates in the opposite row-major order.
Sourcepub const fn get_coords_rmaj(
index: usize,
) -> Result<[usize; 2], IndexOutOfBounds> ⓘ
pub const fn get_coords_rmaj( index: usize, ) -> Result<[usize; 2], IndexOutOfBounds> ⓘ
Calculates the 2D coordinates from the given 1D array index in the opposite row-major order.
§Errors
Returns IndexOutOfBounds
if index
is > CR
.
Sourcepub const fn get_coords_rmaj_unchecked(index: usize) -> [usize; 2]
pub const fn get_coords_rmaj_unchecked(index: usize) -> [usize; 2]
Calculates the 2D coordinates from the given 1D array index in the opposite row-major order.
Source§impl<T: Clone, const C: usize, const R: usize, const CR: usize, S: Storage> Array2d<T, C, R, CR, false, S>
impl<T: Clone, const C: usize, const R: usize, const CR: usize, S: Storage> Array2d<T, C, R, CR, false, S>
Sourcepub fn get_rmaj(&self, col_row: [usize; 2]) -> Result<T, IndexOutOfBounds> ⓘ
pub fn get_rmaj(&self, col_row: [usize; 2]) -> Result<T, IndexOutOfBounds> ⓘ
Returns a clone of the element at the given 2D coordinates in the opposite row-major order.
§Errors
Returns IndexOutOfBounds
if the coordinates are out of bounds.
Sourcepub fn get_rmaj_unchecked(&self, col_row: [usize; 2]) -> T
pub fn get_rmaj_unchecked(&self, col_row: [usize; 2]) -> T
Returns a clone of the element at the given 2D coordinates in the opposite row-major order.
§Panics
Panics if the coordinates are out of bounds.
Source§impl<T, const C: usize, const R: usize, const CR: usize, S: Storage> Array2d<T, C, R, CR, true, S>
§Fundamental indexing methods in row-major order.
impl<T, const C: usize, const R: usize, const CR: usize, S: Storage> Array2d<T, C, R, CR, true, S>
§Fundamental indexing methods in row-major order.
Sourcepub const fn get_index(col_row: [usize; 2]) -> Result<usize, IndexOutOfBounds> ⓘ
pub const fn get_index(col_row: [usize; 2]) -> Result<usize, IndexOutOfBounds> ⓘ
Calculates the 1D array index from the given 2D coordinates in the current row-major order.
§Errors
Returns IndexOutOfBounds
if the resulting index is >= CR
.
Sourcepub const fn get_index_unchecked(col_row: [usize; 2]) -> usize ⓘ
pub const fn get_index_unchecked(col_row: [usize; 2]) -> usize ⓘ
Calculates the 1D array index from the given 2D coordinates in the current row-major order.
Sourcepub const fn get_coords(index: usize) -> Result<[usize; 2], IndexOutOfBounds> ⓘ
pub const fn get_coords(index: usize) -> Result<[usize; 2], IndexOutOfBounds> ⓘ
Calculates the 2D coordinates from the given 1D array index in the current row-major order.
§Errors
Returns IndexOutOfBounds
if index
is >= CR
.
Sourcepub const fn get_coords_unchecked(index: usize) -> [usize; 2]
pub const fn get_coords_unchecked(index: usize) -> [usize; 2]
Calculates the 2D coordinates from the given 1D array index in the current row-major order.
Source§impl<T, const C: usize, const R: usize, const CR: usize, S: Storage> Array2d<T, C, R, CR, false, S>
§Fundamental indexing methods in column-major order.
impl<T, const C: usize, const R: usize, const CR: usize, S: Storage> Array2d<T, C, R, CR, false, S>
§Fundamental indexing methods in column-major order.
Sourcepub const fn get_index(col_row: [usize; 2]) -> Result<usize, IndexOutOfBounds> ⓘ
pub const fn get_index(col_row: [usize; 2]) -> Result<usize, IndexOutOfBounds> ⓘ
Calculates the 1D array index from the given 2D coordinates in the current column-major order.
§Errors
Returns IndexOutOfBounds
if the resulting index is >= CR
.
Sourcepub const fn get_index_unchecked(col_row: [usize; 2]) -> usize ⓘ
pub const fn get_index_unchecked(col_row: [usize; 2]) -> usize ⓘ
Calculates the 1D array index from the given 2D coordinates in the current column-major order.
Sourcepub const fn get_coords(index: usize) -> Result<[usize; 2], IndexOutOfBounds> ⓘ
pub const fn get_coords(index: usize) -> Result<[usize; 2], IndexOutOfBounds> ⓘ
Calculates the 2D coordinates from the given 1D array index in the current column-major order.
§Errors
Returns IndexOutOfBounds
if index
is >= CR
.
Sourcepub const fn get_coords_unchecked(index: usize) -> [usize; 2]
pub const fn get_coords_unchecked(index: usize) -> [usize; 2]
Calculates the 2D coordinates from the given 1D array index in the current column-major order.
Trait Implementations§
Source§impl<T, const C: usize, const R: usize, const CR: usize, const RMAJ: bool, S: Storage> Archive for Array2d<T, C, R, CR, RMAJ, S>
impl<T, const C: usize, const R: usize, const CR: usize, const RMAJ: bool, S: Storage> Archive for Array2d<T, C, R, CR, RMAJ, S>
Source§type Archived = ArchivedArray2d<T, C, R, CR, RMAJ, S>
type Archived = ArchivedArray2d<T, C, R, CR, RMAJ, S>
Source§type Resolver = Array2dResolver<T, C, R, CR, RMAJ, S>
type Resolver = Array2dResolver<T, C, R, CR, RMAJ, S>
Source§fn resolve(&self, resolver: Self::Resolver, out: Place<Self::Archived>)
fn resolve(&self, resolver: Self::Resolver, out: Place<Self::Archived>)
§const COPY_OPTIMIZATION: CopyOptimization<Self> = _
const COPY_OPTIMIZATION: CopyOptimization<Self> = _
serialize
. Read moreSource§impl<T: Clone, const C: usize, const R: usize, const CR: usize, const RMAJ: bool, S: Storage> Clone for Array2d<T, C, R, CR, RMAJ, S>
impl<T: Clone, const C: usize, const R: usize, const CR: usize, const RMAJ: bool, S: Storage> Clone for Array2d<T, C, R, CR, RMAJ, S>
Source§impl<T: ConstDefault, const C: usize, const R: usize, const CR: usize, const RMAJ: bool> ConstDefault for Array2d<T, C, R, CR, RMAJ, Bare>
impl<T: ConstDefault, const C: usize, const R: usize, const CR: usize, const RMAJ: bool> ConstDefault for Array2d<T, C, R, CR, RMAJ, Bare>
Source§impl<T: Debug, const C: usize, const R: usize, const CR: usize, S: Storage, const RMAJ: bool> Debug for Array2d<T, C, R, CR, RMAJ, S>
impl<T: Debug, const C: usize, const R: usize, const CR: usize, S: Storage, const RMAJ: bool> Debug for Array2d<T, C, R, CR, RMAJ, S>
Source§impl<T: Default, const C: usize, const R: usize, const CR: usize, const RMAJ: bool> Default for Array2d<T, C, R, CR, RMAJ, Bare>
impl<T: Default, const C: usize, const R: usize, const CR: usize, const RMAJ: bool> Default for Array2d<T, C, R, CR, RMAJ, Bare>
Source§impl<T: Default, const C: usize, const R: usize, const CR: usize, const RMAJ: bool> Default for Array2d<T, C, R, CR, RMAJ, Boxed>
Available on crate feature alloc
only.
impl<T: Default, const C: usize, const R: usize, const CR: usize, const RMAJ: bool> Default for Array2d<T, C, R, CR, RMAJ, Boxed>
alloc
only.Source§impl<__D: Fallible + ?Sized, T, const C: usize, const R: usize, const CR: usize, const RMAJ: bool, S: Storage> Deserialize<Array2d<T, C, R, CR, RMAJ, S>, __D> for Archived<Array2d<T, C, R, CR, RMAJ, S>>
impl<__D: Fallible + ?Sized, T, const C: usize, const R: usize, const CR: usize, const RMAJ: bool, S: Storage> Deserialize<Array2d<T, C, R, CR, RMAJ, S>, __D> for Archived<Array2d<T, C, R, CR, RMAJ, S>>
Source§impl<T: PartialEq, const C: usize, const R: usize, const CR: usize, const RMAJ: bool, S: Storage> PartialEq for Array2d<T, C, R, CR, RMAJ, S>
impl<T: PartialEq, const C: usize, const R: usize, const CR: usize, const RMAJ: bool, S: Storage> PartialEq for Array2d<T, C, R, CR, RMAJ, S>
Source§impl<__S: Fallible + ?Sized, T, const C: usize, const R: usize, const CR: usize, const RMAJ: bool, S: Storage> Serialize<__S> for Array2d<T, C, R, CR, RMAJ, S>
impl<__S: Fallible + ?Sized, T, const C: usize, const R: usize, const CR: usize, const RMAJ: bool, S: Storage> Serialize<__S> for Array2d<T, C, R, CR, RMAJ, S>
impl<T: Copy, const C: usize, const R: usize, const CR: usize, const RMAJ: bool, S: Storage> Copy for Array2d<T, C, R, CR, RMAJ, S>
impl<T: Eq, const C: usize, const R: usize, const CR: usize, const RMAJ: bool, S: Storage> Eq for Array2d<T, C, R, CR, RMAJ, S>
Auto Trait Implementations§
impl<T, const C: usize, const R: usize, const CR: usize, const RMAJ: bool, S> Freeze for Array2d<T, C, R, CR, RMAJ, S>
impl<T, const C: usize, const R: usize, const CR: usize, const RMAJ: bool, S> RefUnwindSafe for Array2d<T, C, R, CR, RMAJ, S>
impl<T, const C: usize, const R: usize, const CR: usize, const RMAJ: bool, S> Send for Array2d<T, C, R, CR, RMAJ, S>
impl<T, const C: usize, const R: usize, const CR: usize, const RMAJ: bool, S> Sync for Array2d<T, C, R, CR, RMAJ, S>
impl<T, const C: usize, const R: usize, const CR: usize, const RMAJ: bool, S> Unpin for Array2d<T, C, R, CR, RMAJ, S>
impl<T, const C: usize, const R: usize, const CR: usize, const RMAJ: bool, S> UnwindSafe for Array2d<T, C, R, CR, RMAJ, S>
Blanket Implementations§
§impl<T> ArchivePointee for T
impl<T> ArchivePointee for T
§type ArchivedMetadata = ()
type ArchivedMetadata = ()
§fn pointer_metadata(
_: &<T as ArchivePointee>::ArchivedMetadata,
) -> <T as Pointee>::Metadata
fn pointer_metadata( _: &<T as ArchivePointee>::ArchivedMetadata, ) -> <T as Pointee>::Metadata
§impl<T> ArchiveUnsized for Twhere
T: Archive,
impl<T> ArchiveUnsized for Twhere
T: Archive,
§type Archived = <T as Archive>::Archived
type Archived = <T as Archive>::Archived
Archive
, it may be
unsized. Read more§fn archived_metadata(
&self,
) -> <<T as ArchiveUnsized>::Archived as ArchivePointee>::ArchivedMetadata
fn archived_metadata( &self, ) -> <<T as ArchiveUnsized>::Archived as ArchivePointee>::ArchivedMetadata
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
Source§impl<T> ByteSized for T
impl<T> ByteSized for T
Source§const BYTE_ALIGN: usize = _
const BYTE_ALIGN: usize = _
Source§fn byte_align(&self) -> usize ⓘ
fn byte_align(&self) -> usize ⓘ
Source§fn ptr_size_ratio(&self) -> [usize; 2]
fn ptr_size_ratio(&self) -> [usize; 2]
Source§impl<T, R> Chain<R> for Twhere
T: ?Sized,
impl<T, R> Chain<R> for Twhere
T: ?Sized,
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key
and return true
if they are equal.Source§impl<T> ExtAny for T
impl<T> ExtAny for T
Source§fn as_any_mut(&mut self) -> &mut dyn Anywhere
Self: Sized,
fn as_any_mut(&mut self) -> &mut dyn Anywhere
Self: Sized,
Source§impl<T> ExtMem for Twhere
T: ?Sized,
impl<T> ExtMem for Twhere
T: ?Sized,
Source§const NEEDS_DROP: bool = _
const NEEDS_DROP: bool = _
Source§fn mem_align_of_val(&self) -> usize ⓘ
fn mem_align_of_val(&self) -> usize ⓘ
Source§fn mem_size_of_val(&self) -> usize ⓘ
fn mem_size_of_val(&self) -> usize ⓘ
Source§fn mem_needs_drop(&self) -> bool
fn mem_needs_drop(&self) -> bool
true
if dropping values of this type matters. Read moreSource§fn mem_forget(self)where
Self: Sized,
fn mem_forget(self)where
Self: Sized,
self
without running its destructor. Read moreSource§fn mem_replace(&mut self, other: Self) -> Selfwhere
Self: Sized,
fn mem_replace(&mut self, other: Self) -> Selfwhere
Self: Sized,
Source§unsafe fn mem_zeroed<T>() -> T
unsafe fn mem_zeroed<T>() -> T
unsafe_layout
only.T
represented by the all-zero byte-pattern. Read moreSource§unsafe fn mem_transmute_copy<Src, Dst>(src: &Src) -> Dst
unsafe fn mem_transmute_copy<Src, Dst>(src: &Src) -> Dst
unsafe_layout
only.T
represented by the all-zero byte-pattern. Read moreSource§fn mem_as_bytes(&self) -> &[u8] ⓘ
fn mem_as_bytes(&self) -> &[u8] ⓘ
unsafe_slice
only.§impl<S> FromSample<S> for S
impl<S> FromSample<S> for S
fn from_sample_(s: S) -> S
Source§impl<T> Hook for T
impl<T> Hook for T
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
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> ⓘ
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> ⓘ
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§impl<F, T> IntoSample<T> for Fwhere
T: FromSample<F>,
impl<F, T> IntoSample<T> for Fwhere
T: FromSample<F>,
fn into_sample(self) -> T
§impl<T> LayoutRaw for T
impl<T> LayoutRaw for T
§fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError> ⓘ
fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError> ⓘ
§impl<T, N1, N2> Niching<NichedOption<T, N1>> for N2
impl<T, N1, N2> Niching<NichedOption<T, N1>> for N2
§unsafe fn is_niched(niched: *const NichedOption<T, N1>) -> bool
unsafe fn is_niched(niched: *const NichedOption<T, N1>) -> bool
§fn resolve_niched(out: Place<NichedOption<T, N1>>)
fn resolve_niched(out: Place<NichedOption<T, N1>>)
out
indicating that a T
is niched.