Hello,
I have enum:
pub const BuiltinCommand = enum {
exit,
echo,
type,
pwd,
cd
};
defined at enums.zig file,
I am importing that file, and want to iterate over members of that enum, so I wrote:
fn _set_builtin_commands(self: *CommandMap) !void {
for (std.meta.fields(enums.BuiltinCommand)) |command| {
try self.map.put(
try self.arena_allocator.dupe(@tagName(command)),
.{
.buildin_command = command
}
);
}
}
But it raises error that says:
error: values of type '[]const builtin.Type.EnumField' must be comptime-known, but index value is runtime-known
I don't get it, this enums are comptime known right? Why I am getting this error, and how to fix that.
thanks for help!