nodefish
nodefish
Sent PR
`@memberIndex` can be done in userland now: ```zig fn memberIndex(comptime T: type, tag: T) usize { const enum_info = @typeInfo(T); const enum_fields = enum_info.Enum.fields; inline for (enum_fields) |field, i| {...
EnumArray: ```zig fn EnumArray(comptime T: type, comptime U: type) type { return struct { data: [@memberCount(T)]U, fn get(self: *const @This(), tag: T) U { return self.data[memberIndex(T, tag)]; } fn set(self:...
From the article posted by @monouser7dig: >They do not change the runtime code, but they can prevent a lot of errors at compile time. > Sounds like a job for...
>how would comptime provide this feature? You're right, I conflated this with the "strong typedefs" described in the article posted above. They are distinct concepts after all, no pun intended.
Is this not typically a job for some kind of interfaces, i.e. allow anything that implements `IError` to be used for the error control flow syntax? This would play nicely...