News for hackers. Stuff that matters.
Re:Packed structs in Zig make bit/flag sets trivial by elcritch on Tuesday August 30, 2022 @02:59AM (#32647425)
I've come to really like Nim's built-in `set` type for that sorta scenario. It's just a bit-vector but it took me months before I realized that. You can cast an `int32` to a `set[MyEnum]` and be able to do set unions, differences, etc. Makes it easy to define a mask just by `const myMask = {A, B, E}`.

Making a Zig BitSet would probably be doable, for those cases where bitfields are overkill.

1: https://nim-lang.org/docs/manual.html#types-set-type

There are no comments on this comment yet.