# ComptimeStringMap: expose kvs array in returned struct · gitcafe/zig

[View on GitCafe](https://git.cafe/gitcafe/zig/commit/7e07df06a4f1507be216c84b034167cdee1817f7)

Repository: [gitcafe/zig](https://git.cafe/gitcafe/zig)

Visibility: public

Requested revision: 7e07df06a4f1507be216c84b034167cdee1817f7

Requested commit: 7e07df06a4f1507be216c84b034167cdee1817f7

Commit: 7e07df06a4f1507be216c84b034167cdee1817f7

Tree: 4a7aa2c694cd784f5d4a3c85418621d8b1612d49

Author: Ryan Liptak

Committer: Ryan Liptak

## Message

```
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| {}

```

## Parents

- [8ff49966bc9d6d7438640fa475e95f9a24a4b931](https://git.cafe/gitcafe/zig/commit/8ff49966bc9d6d7438640fa475e95f9a24a4b931?format=markdown)

[Source at this commit](https://git.cafe/gitcafe/zig/tree/7e07df06a4f1507be216c84b034167cdee1817f7?format=markdown)
