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§
Sourcefn from_index(u: usize) -> Self
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.