# std.enums: allow non-exhaustive enums in EnumIndexer and make \`count\` comptime_int instead of usize · gitcafe/zig

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

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

Visibility: public

Requested revision: 4e212f16506b88d934d9a0c559fa6b2e0e88574e

Requested commit: 4e212f16506b88d934d9a0c559fa6b2e0e88574e

Commit: 4e212f16506b88d934d9a0c559fa6b2e0e88574e

Tree: 5593aa70f985b759e7633e08d3e4bcd2642513f8

Author: Eric Joldasov

Committer: Veikka Tuominen

## Message

```
std.enums: allow non-exhaustive enums in EnumIndexer and make `count` comptime_int instead of usize

Seems like this restriction was actual when Ziglang had extern enums,
but now it's not neccessary and can be lifted. It was present since
original PR which introduced std.enums, https://www.github.com/ziglang/zig/pull/8171.
See also: https://ziggit.dev/t/catching-invalid-enum-value-errors/2206/11

* Make `count` comptime_int instead of usize

With previous type, creating EnumIndexer for enum(usize) and enum(isize)
would cause compile error since `count` could not store maxInt(usize) + 1.
Now it can store it and reflects len field from std.builtin.Type.Array
(most common use case of count field inside std.enums functions is creating arrays).

Signed-off-by: Eric Joldasov <bratishkaerik@getgoogleoff.me>

```

## Parents

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

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