0
Fork 0
mirror of https://codeberg.org/ziglang/zig synced 2026-11-18 07:05:05 +00:00

ComptimeStringMap: expose kvs array in returned struct

Allows for iterating over the kvs when constructing with a list literal instead of having to create a separate array to pass into ComptimeStringMap in order to maintain access to the values.

For example when making a set, before in order to loop over the kvs you'd have to do something like:

    const MyKV = struct { @"0": []const u8 };
    const kvs: []const MyKV = &[_]MyKV{ .{ @"0" = "foo"}, .{ @"0" = "bar" } };
    const map = ComptimeStringMap(void, kvs);
    for (kvs) |kv| {}

whereas now it's possible to do:

    const map = ComptimeStringMap(void, .{ .{"foo"}, .{"bar"} });
    for (map.kvs) |kv| {}
This commit is contained in:
Ryan Liptak 2021-08-13 16:16:29 -07:00
commit 7e07df06a4