Trait orx_funvec::IntoIndex
source · pub trait IntoIndex<const DIM: usize> {
// Required method
fn into_index(self) -> [usize; DIM];
}Expand description
A convenience trait to allow accepting and interchangeably using indices as arrays or tuples.
A struct implementing IntoIndex<DIM> can be converted into and index represented as [usize; DIM], such as:
usize,(usize),[usize; 1]implementIntoIndex<1>, and hence, can be converted into[usize; 1];(usize, usize),[usize; 2]implementIntoIndex<2>, and hence, can be converted into[usize; 2];- …
Required Methods§
sourcefn into_index(self) -> [usize; DIM]
fn into_index(self) -> [usize; DIM]
Converts the value into an index represented as [usize; DIM].
Example
use orx_funvec::*;
let i = 2;
let index = i.into_index();
assert_eq!(index, [2]);
let ij = (3, 4);
let index = ij.into_index();
assert_eq!(index, [3, 4]);