I think you could find inspiration in the implementation of BitSets and IntSets since they both do low-level bit manipulation and operate on arrays of bytes. BitSets have a fixed memory size while IntSets are dynamically allocated/resized and use refs (GC'ed memory).
[https://github.com/nim-lang/Nim/blob/5f685bb0e6b2d68b9796e6a7d29469ce3f3b38ec/compiler/bitsets.nim](https://github.com/nim-lang/Nim/blob/5f685bb0e6b2d68b9796e6a7d29469ce3f3b38ec/compiler/bitsets.nim) [https://github.com/nim-lang/Nim/blob/df4f707743879a0ea4363fcef446d89d8b421513/lib/pure/collections/intsets.nim](https://github.com/nim-lang/Nim/blob/df4f707743879a0ea4363fcef446d89d8b421513/lib/pure/collections/intsets.nim)
