I'm trying to initialize some fields of a union. Since they don't have the same type, I have to match on their variants inside an inline loop. I can't quite figure out the syntax, though:
const Conf = union(enum) {
modules: std.EnumArray(ModulesList, std.StringHashMap(void)),
defaults: std.EnumArray(ModulesList, []const u8),
};
pub fn doSmth() !void {
inline for (std.meta.fields(Conf)) |f| {
// this is wrong,
//f.type gives me the type of the field, not its variant
const mod = switch (f.type) {
.modules => std.EnumArray(ModulesList, std.StringHashMap(void)).init(),
.defaults => std.EnumArray(ModulesList, []const u8).init(.{}),
};
}
}

