Trait orx_funvec::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);

Object Safety§

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§