authorgravatar for jmrico01@gmail.comJosé M Rico <jmrico01@gmail.com> 2024-11-06 04:15:56-05:00
committergravatar for noreply@github.comGitHub <noreply@github.com> 2024-11-06 09:15:56+00:00
log54d0ba418375a4665cf1b4ee876d6c750bb9c079
tree558e3d7a860c9ead6335a5f8306df8fde12e71e3
parented04acf90dad41b24d7e11168a0fdd3316fc6f82
signaturebadge-check Signed by PGP key B5690EEEBB952194

std: fix `Random.enumValueWithIndex` of single-variant enum


1 files changed, 1 insertions(+), 1 deletions(-)

lib/std/Random.zig+1-1
...@@ -86,7 +86,7 @@ pub fn enumValueWithIndex(r: Random, comptime EnumType: type, comptime Index: ty...@@ -86,7 +86,7 @@ pub fn enumValueWithIndex(r: Random, comptime EnumType: type, comptime Index: ty
86 const values = comptime std.enums.values(EnumType);86 const values = comptime std.enums.values(EnumType);
87 comptime assert(values.len > 0); // can't return anything87 comptime assert(values.len > 0); // can't return anything
88 comptime assert(maxInt(Index) >= values.len - 1); // can't access all values88 comptime assert(maxInt(Index) >= values.len - 1); // can't access all values
89 comptime if (values.len == 1) return values[0];89 if (values.len == 1) return values[0];
9090
91 const index = if (comptime values.len - 1 == maxInt(Index))91 const index = if (comptime values.len - 1 == maxInt(Index))
92 r.int(Index)92 r.int(Index)