# Why doesn't Zig have std.HashSet?

**URL:** <https://ziggit.dev/t/why-doesnt-zig-have-std-hashset/17363>\
**Category:** Explain\
**Created:** [August 25, 2026, 6:59pm UTC](https://ziggit.dev/t/why-doesnt-zig-have-std-hashset/17363 "2026-08-25T18:59:26Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![giluis](https://ziggit.dev/user_avatar/ziggit.dev/giluis/32/5886_2.png) [@giluis](https://ziggit.dev/u/giluis)\
**Post date:** [August 25, 2026, 6:59pm UTC](https://ziggit.dev/t/why-doesnt-zig-have-std-hashset/17363/1 "2026-08-25T18:59:27Z")

</div>

We can use `std.HashMap` with the Key=\<your set element type\> and Value=void, but seems hacky: the API isn’t as good as it could be e.g. you have to treat keys as your values and disregard a big part of the API.  
[This issue exists](https://github.com/ziglang/zig/issues/6919), but was closed without comment.  
Does anyone know why std does not / cannot have HashSet? Wondering if there’s a good reason I’m not seeing

---

<div class="post-metadata">

**Author:** ![spiffyk](https://ziggit.dev/user_avatar/ziggit.dev/spiffyk/32/7202_2.png) [@spiffyk](https://ziggit.dev/u/spiffyk)\
**Post date:** [August 25, 2026, 7:14pm UTC](https://ziggit.dev/t/why-doesnt-zig-have-std-hashset/17363/2 "2026-08-25T19:14:48Z")

</div>

It’s not worth the maintenance burden when you can just use the aforementioned `std.HashMap(T, void)`. It’d surely just be implemented as a weird API-reducing wrapper around it anyway. Zig doesn’t really do abstractions just for the sake of doing abstractions.

---

<div class="post-metadata">

**Author:** ![pierrelgol](https://ziggit.dev/user_avatar/ziggit.dev/pierrelgol/32/10233_2.png) [@pierrelgol](https://ziggit.dev/u/pierrelgol)\
**Post date:** [August 25, 2026, 10:14pm UTC](https://ziggit.dev/t/why-doesnt-zig-have-std-hashset/17363/3 "2026-08-25T22:14:06Z")

</div>

I agree the lack of a proper hash set is a bit annoying, but like mentioned before `std.HashMap(T, void)` works. But it could eventually land, there’s an issue on github, which details that the plan is to first finish the language, stabilize it, offer tier 1 support for more targets, and then focus on auditing the std, to improve it.

Right now the std is in a weird position, in the sense that it’s essentially a byproduct of the compiler’s need (although really well designed IMO and thoughtfully written API). I don’t know if they have decided on a strategy for the std (aka batteries included or basic building blocks only).

So it’s impossible to know what the future will offer, but essentially it could go both ways and something like a proper hashset could live in the std. Or not at all, right now it’s probably best to copy/paste the std.hashmap rework it into a proper hashset, put it on github as a package and use it this way.

---

<div class="post-metadata">

**Author:** ![Cloudef](https://ziggit.dev/user_avatar/ziggit.dev/cloudef/32/1370_2.png) [@Cloudef](https://ziggit.dev/u/Cloudef)\
**Post date:** [August 25, 2026, 10:34pm UTC](https://ziggit.dev/t/why-doesnt-zig-have-std-hashset/17363/4 "2026-08-25T22:34:41Z")

</div>

`std.AutoArrayHashMapUnamanaged` might be slightly better than `std.HashMap`, well in general not just for sets.

There’s also `std.enums.EnumSet`.

---

<div class="post-metadata">

**Author:** ![saurabh](https://ziggit.dev/user_avatar/ziggit.dev/saurabh/32/4623_2.png) [@saurabh](https://ziggit.dev/u/saurabh)\
**Post date:** [August 25, 2026, 10:43pm UTC](https://ziggit.dev/t/why-doesnt-zig-have-std-hashset/17363/5 "2026-08-25T22:43:25Z")

</div>

> [@spiffyk](#):
>
> It’s not worth the maintenance burden when you can just use the aforementioned `std.HashMap(T, void)`.

Another example of this is `std.PriorityQueue` and `std.PriorityDequeue` - I think having one covers all the use cases of the other.

---

<div class="post-metadata">

**Author:** ![pierrelgol](https://ziggit.dev/user_avatar/ziggit.dev/pierrelgol/32/10233_2.png) [@pierrelgol](https://ziggit.dev/u/pierrelgol)\
**Post date:** [August 26, 2026, 8:19am UTC](https://ziggit.dev/t/why-doesnt-zig-have-std-hashset/17363/6 "2026-08-26T08:19:21Z")

</div>

That’s true 🙂
