bitset

A pure nim version of C++'s std::bitset

Pure Nim score 15/100 · tests present · no docs generated

Summary

Latest Version Unknown
License MIT
CI Status Failing
Downloads 0
Last Indexed 2026-07-21 05:24

Installation

nimble install bitset
choosenim install bitset
git clone https://github.com/joryschossau/bitset

OS Compatibility

Platform Linux macOS Windows FreeBSD OpenBSD NetBSD Android iOS WASM Embedded
bitset - - - - - - -

Source

Repository https://github.com/joryschossau/bitset
Homepage https://github.com/joryschossau/bitset
Registry Source nimble_official

README

bitset nim module

std::bitset implementation in pure nim, with identical signatures. It also includes the same kind of raw memory layout behavior enabling byte-level casting, just like std::bitset.

import bitset

var bs:Bitset[210] # 210 bits, or 27 bytes allocated (not all of 27th byte used)

# set a decimal value of 14 in binary
bs[0] = 0 # not necessary
bs[1] = 1
bs[2] = 1
bs[3] = 1

echo bs # 0000...<redacted>...00001110

assert bs.len() == 210
assert sizeof bs == 27
assert bs.bytes[0] == 14
assert bs.count() == 3
assert bs.unsafeAddr == bs.bytes[0].unsafeAddr

Possible Future Features

Perhaps having more canonical nim-like interface would be nice, like range accessors for setting/getting, and maybe an iterator should be implemented.