authorgravatar for yujiri@disroot.orgEvin Yulo <yujiri@disroot.org> 2022-10-16 05:31:29+00:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2022-10-16 11:35:27-04:00
logb346d48572c99f809913cced8910a04d6699701d
tree3b53bc659f01cba47fc1661737fc85f1c0daed11
parentc37b40248ca16a181323cca56616adf7617ca1a6

Simplify code in std.meta.isTag


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

lib/std/meta.zig+1-1
...@@ -68,7 +68,7 @@ pub fn isTag(tagged_value: anytype, comptime tag_name: []const u8) bool {...@@ -68,7 +68,7 @@ pub fn isTag(tagged_value: anytype, comptime tag_name: []const u8) bool {
68 const type_name = @typeName(T);68 const type_name = @typeName(T);
6969
70 // select the Enum type out of the type (in the case of the tagged union, extract it)70 // select the Enum type out of the type (in the case of the tagged union, extract it)
71 const E = if (.Enum == type_info) T else if (.Union == type_info) (if (type_info.Union.tag_type) |TT| TT else {71 const E = if (.Enum == type_info) T else if (.Union == type_info) (type_info.Union.tag_type orelse {
72 @compileError("attempted to use isTag on the untagged union " ++ type_name);72 @compileError("attempted to use isTag on the untagged union " ++ type_name);
73 }) else {73 }) else {
74 @compileError("attempted to use isTag on a value of type (" ++ type_name ++ ") that isn't an enum or a union.");74 @compileError("attempted to use isTag on a value of type (" ++ type_name ++ ") that isn't an enum or a union.");