# InternPool: safer enum API · gitcafe/zig

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

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

Visibility: public

Requested revision: 7ef1eb1c27754cb0349fdc10db1f02ff2dddd99b

Requested commit: 7ef1eb1c27754cb0349fdc10db1f02ff2dddd99b

Commit: 7ef1eb1c27754cb0349fdc10db1f02ff2dddd99b

Tree: 6a76839d8be347648741e17f50d6c70d8313adc3

Author: Andrew Kelley

Committer: Andrew Kelley

## Message

````
InternPool: safer enum API

The key changes in this commit are:

```diff
-        names: []const NullTerminatedString,
+        names: NullTerminatedString.Slice,
-        values: []const Index,
+        values: Index.Slice,
```

Which eliminates the slices from `InternPool.Key.EnumType` and replaces
them with structs that contain `start` and `len` indexes. This makes the
lifetime of `EnumType` change from expiring with updates to InternPool,
to expiring when the InternPool is garbage-collected, which is currently
never.

This is gearing up for a larger change I started working on locally
which moves union types into InternPool.

As a bonus, I fixed some unnecessary instances of `@as`.

````

## Parents

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

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