mirror of
https://github.com/ziglang/zig.git
synced 2024-11-26 15:12:31 +00:00
std: fix Random.enumValueWithIndex
of single-variant enum
Some checks are pending
ci / x86_64-linux-debug (push) Waiting to run
ci / x86_64-linux-release (push) Waiting to run
ci / aarch64-linux-debug (push) Waiting to run
ci / aarch64-linux-release (push) Waiting to run
ci / x86_64-macos-release (push) Waiting to run
ci / aarch64-macos-debug (push) Waiting to run
ci / aarch64-macos-release (push) Waiting to run
ci / x86_64-windows-debug (push) Waiting to run
ci / x86_64-windows-release (push) Waiting to run
ci / aarch64-windows (push) Waiting to run
Some checks are pending
ci / x86_64-linux-debug (push) Waiting to run
ci / x86_64-linux-release (push) Waiting to run
ci / aarch64-linux-debug (push) Waiting to run
ci / aarch64-linux-release (push) Waiting to run
ci / x86_64-macos-release (push) Waiting to run
ci / aarch64-macos-debug (push) Waiting to run
ci / aarch64-macos-release (push) Waiting to run
ci / x86_64-windows-debug (push) Waiting to run
ci / x86_64-windows-release (push) Waiting to run
ci / aarch64-windows (push) Waiting to run
This commit is contained in:
parent
ed04acf90d
commit
54d0ba4183
@ -86,7 +86,7 @@ pub fn enumValueWithIndex(r: Random, comptime EnumType: type, comptime Index: ty
|
||||
const values = comptime std.enums.values(EnumType);
|
||||
comptime assert(values.len > 0); // can't return anything
|
||||
comptime assert(maxInt(Index) >= values.len - 1); // can't access all values
|
||||
comptime if (values.len == 1) return values[0];
|
||||
if (values.len == 1) return values[0];
|
||||
|
||||
const index = if (comptime values.len - 1 == maxInt(Index))
|
||||
r.int(Index)
|
||||
|
Loading…
Reference in New Issue
Block a user