pub unsafe trait Indexable {
type Iter: Iterator<Item = Self>;
const SIZE: usize;
const SET_SIZE: usize;
// Required methods
fn index(self) -> usize;
fn iter() -> Self::Iter;
}
Expand description
Allows mapping from a type to an index
§Safety
This trait is unsafe because there are a few other requirements that need to be met:
- The indexes of self need to be contiguous and need to be returned in order from
iter()
- Iter needs to return exactly N items (this is checked in debug mode)
Required Associated Constants§
Required Associated Types§
Sourcetype Iter: Iterator<Item = Self>
type Iter: Iterator<Item = Self>
The type of Iterator that will be returned by Self::iter()
Required Methods§
Sourcefn index(self) -> usize
fn index(self) -> usize
Maps self to usize to know which value in the underling array to use
§Safety
This value can never be greater than Self::SIZE
All values in 0..SIZE
must be returned by some variant of 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.