std.mem.zeroes: explicit compile error for @Type(.EnumLiteral)

This commit is contained in:
Bogdan Romanyuk 2024-06-24 03:43:09 +03:00 committed by GitHub
parent 1ede3af9f6
commit ab4c461b76
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -224,7 +224,7 @@ pub fn zeroes(comptime T: type) T {
.ComptimeInt, .Int, .ComptimeFloat, .Float => {
return @as(T, 0);
},
.Enum, .EnumLiteral => {
.Enum => {
return @as(T, @enumFromInt(0));
},
.Void => {
@ -291,6 +291,7 @@ pub fn zeroes(comptime T: type) T {
}
@compileError("Can't set a " ++ @typeName(T) ++ " to zero.");
},
.EnumLiteral,
.ErrorUnion,
.ErrorSet,
.Fn,