pub trait FromIndex: Index + Sized {
// Required methods
fn from_index(index: <Self as Index>::Type) -> Option<Self>;
unsafe fn from_index_unchecked(index: <Self as Index>::Type) -> Self;
}
Expand description
Derive this trait for an enum automatically using #[derive(EnumFromIndex)]
Required Methods§
Sourcefn from_index(index: <Self as Index>::Type) -> Option<Self>
fn from_index(index: <Self as Index>::Type) -> Option<Self>
Tries to construct Self
from an index based on the variants’ defined order
Sourceunsafe fn from_index_unchecked(index: <Self as Index>::Type) -> Self
unsafe fn from_index_unchecked(index: <Self as Index>::Type) -> Self
Constructs Self
from an index based on the variants’ defined order
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.