pub trait FromIndex<const DIM: usize> {
// Required method
fn from_index(index: [usize; DIM]) -> Self;
}
Expand description
A convenience trait to allow extending FunVec
implementations.
A struct implementing FromIndex<DIM>
can be created from [usize; DIM]
, such as:
usize
,(usize)
,[usize; 1]
implementFromIndex<1>
, and hence, can be created from[usize; 1]
;(usize, usize)
,[usize; 2]
implementFromIndex<2>
, and hence, can be created from[usize; 2]
;- …
Required Methods§
Sourcefn from_index(index: [usize; DIM]) -> Self
fn from_index(index: [usize; DIM]) -> Self
Converts the index [usize; DIM]
into value.
§Example
use orx_funvec::*;
let index = [2];
let i = usize::from_index(index);
assert_eq!(i, 2);
let index = [3, 4];
let (i, j) = <(usize, usize)>::from_index(index);
assert_eq!(i, 3);
assert_eq!(j, 4);
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.