diff --git a/source/coral/io.zig b/source/coral/io.zig index 7961cfc..deba662 100755 --- a/source/coral/io.zig +++ b/source/coral/io.zig @@ -84,6 +84,14 @@ pub const Reader = struct { } }; +pub fn Tag(comptime Element: type) type { + return switch (@typeInfo(Element)) { + .Enum => |info| info.tag_type, + .Union => |info| info.tag_type orelse @compileError(@typeName(Element) ++ " has no tag type"), + else => @compileError("expected enum or union type, found '" ++ @typeName(Element) ++ "'"), + }; +} + pub const WriteError = error{ IoUnavailable, };