Packed structs in Zig make bit/flag sets trivial

Open link in next tab

Packed structs in Zig make bit/flag sets trivial

https://devlog.hexops.com/2022/packed-structs-in-zig/

As we've been building Mach engine, we've been using a neat little pattern in Zig that enables writing flag sets more nicely in Zig than in other languages. Here's a brief explainer.

Packed structs in Zig make bit/flag sets trivial

Bumped into this article about bit-sized booleans in Zig packed structs, thought it might be interesting to others.