fn enumValueWithIndex(r: Random, comptime EnumType: type, comptime Index: type) EnumType

Returns a random value from an enum, evenly distributed.

An index into an array of all named values is generated using the specified Index type to determine the return value. This allows for results to be independent of usize representation.

Prefer enumValue if this isn’t important.

See uintLessThan, which this function uses in most cases, for commentary on the runtime of this function.

Parameters

r: Random,
EnumType: type,
Index: type,