Trait ReverseIndexable

Source
pub unsafe trait ReverseIndexable: Indexable {
    // Required method
    fn from_index(u: usize) -> Self;
}
Expand description

Allows mapping from an index to a type

§Safety

This is trait is unsafe because it needs to uphold the property that it is reflexive. For example:

use array_map::*;
let index = 42_u8.index();
let u = u8::from_index(index);
assert_eq!(u, 42);

If a value greater than or equal to Self::SIZE is provided, then this function can panic. This library will never pass in an invalid usize value.

Required Methods§

Source

fn from_index(u: usize) -> Self

Converts from a usize to Self

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 ReverseIndexable for bool

Source§

fn from_index(u: usize) -> Self

Source§

impl ReverseIndexable for u8

Source§

fn from_index(u: usize) -> Self

Source§

impl ReverseIndexable for u16

Source§

fn from_index(u: usize) -> Self

Source§

impl<T, U> ReverseIndexable for (T, U)

Source§

fn from_index(u: usize) -> Self

Source§

impl<T, U, V> ReverseIndexable for (T, U, V)

Source§

fn from_index(u: usize) -> Self

Source§

impl<T: ReverseIndexable> ReverseIndexable for Option<T>

Source§

fn from_index(u: usize) -> Self

Implementors§

Source§

impl<const N: u8> ReverseIndexable for IndexU8<N>

Source§

impl<const N: u16> ReverseIndexable for IndexU16<N>