aboutsummaryrefslogtreecommitdiff
path: root/lib/std/meta.zig
diff options
context:
space:
mode:
authorAndrew Kelley <andrew@ziglang.org>2022-12-08 02:23:17 -0800
committerAndrew Kelley <andrew@ziglang.org>2022-12-08 02:23:17 -0800
commit225ed65ed2cc88fce54660250feaeb44e45943fa (patch)
tree53912cecb13cf5ddfa10ae19db1917b1f28644a3 /lib/std/meta.zig
parentd5ecb318c4550351eb1973d73cac61bc8af2a70f (diff)
downloadzig-225ed65ed2cc88fce54660250feaeb44e45943fa.tar.gz
zig-225ed65ed2cc88fce54660250feaeb44e45943fa.zip
Revert "std.ComptimeStringMap: use tuple types"
This reverts commit 096d3efae5fcaa5640f4acb2f9be2d7f93f7fdb2. This commit is not passing a very important CI test that was recently added.
Diffstat (limited to 'lib/std/meta.zig')
-rw-r--r--lib/std/meta.zig10
1 files changed, 8 insertions, 2 deletions
diff --git a/lib/std/meta.zig b/lib/std/meta.zig
index 9dd1a97baf..b2fd10107b 100644
--- a/lib/std/meta.zig
+++ b/lib/std/meta.zig
@@ -115,10 +115,16 @@ pub fn stringToEnum(comptime T: type, str: []const u8) ?T {
// - https://github.com/ziglang/zig/issues/3863
if (@typeInfo(T).Enum.fields.len <= 100) {
const kvs = comptime build_kvs: {
- const EnumKV = struct { []const u8, T };
+ // In order to generate an array of structs that play nice with anonymous
+ // list literals, we need to give them "0" and "1" field names.
+ // TODO https://github.com/ziglang/zig/issues/4335
+ const EnumKV = struct {
+ @"0": []const u8,
+ @"1": T,
+ };
var kvs_array: [@typeInfo(T).Enum.fields.len]EnumKV = undefined;
inline for (@typeInfo(T).Enum.fields) |enumField, i| {
- kvs_array[i] = .{ enumField.name, @field(T, enumField.name) };
+ kvs_array[i] = .{ .@"0" = enumField.name, .@"1" = @field(T, enumField.name) };
}
break :build_kvs kvs_array[0..];
};