Trait FromIndex

Source
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] implement FromIndex<1>, and hence, can be created from [usize; 1];
  • (usize, usize), [usize; 2] implement FromIndex<2>, and hence, can be created from [usize; 2];

Required Methods§

Source

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.

Implementations on Foreign Types§

Source§

impl FromIndex<DIM> for (usize, usize)

Source§

fn from_index(index: [usize; 2]) -> Self

Source§

impl FromIndex<DIM> for (usize, usize, usize)

Source§

fn from_index(index: [usize; 3]) -> Self

Source§

impl FromIndex<DIM> for (usize, usize, usize, usize)

Source§

fn from_index(index: [usize; 4]) -> Self

Source§

impl FromIndex<DIM> for usize

Source§

fn from_index(index: [usize; 1]) -> Self

Source§

impl<const DIM: usize> FromIndex<DIM> for [usize; DIM]

Source§

fn from_index(index: [usize; DIM]) -> Self

Implementors§