Trait IndexEnum
pub trait IndexEnum: EngineEnum {
const ENUMERATOR_COUNT: usize;
// Provided method
fn to_index(self) -> usize { ... }
}
Expand description
Trait for enums that can be used as indices in arrays.
The conditions for a Godot enum to be “index-like” are:
- Contains an enumerator ending in
_MAX
, which has the highest ordinal (denotes the size). - All other enumerators are consecutive integers inside
0..max
(no negative ordinals, no gaps).
Duplicates are explicitly allowed, to allow for renamings/deprecations. The order in which Godot exposes the enumerators in the JSON is irrelevant.
Required Associated Constants§
const ENUMERATOR_COUNT: usize
const ENUMERATOR_COUNT: usize
Number of distinct enumerators in the enum.
All enumerators are guaranteed to be in the range 0..ENUMERATOR_COUNT
, so you can use them
as indices in an array of size ENUMERATOR_COUNT
.
Keep in mind that two enumerators with the same ordinal are only counted once.
Provided Methods§
Object Safety§
This trait is not object safe.