natbitset

Crates.ionatbitset
lib.rsnatbitset
version0.2.0
created_at2026-01-21 22:42:31.731262+00
updated_at2026-01-24 16:50:43.082666+00
descriptionA lightweight set implementation for consecutive natural numbers
homepage
repositoryhttps://github.com/Sup2point0/natbitset
max_upload_size
id2060269
size32,856
Sup#2.0 (Sup2point0)

documentation

https://docs.rs/natbitset/latest/natbitset

README

Bitflags for Natural Numbers

A super-lightweight set implementation for consecutive natural numbers 1..=N.1

Quickstart

use natbitset::*;

let bitset = Bitset::<8>::from([1,2,3]);

bitset.members();  // => HashSet {1,2,3}

*bitset;  // => 0b_0000_0111

bitset += 4;  // => Bitset(0b_0000_1111)

bitset |= Bitset::<8>::from([4,5,6]);  // => Bitset(0b_0011_1111)

bitset &= Bitset::<8>::from([1,3,7]);  // => Bitset(0b_0000_0101)

For more detailed guidance on how to use the struct, as well as an explanation of how it works, please visit the documentation on docs.rs!

Changelog

View the Changelog in the GitHub repository.

Footnotes

  1. I’m of the opinion that $0$ is a natural number, but unfortunately “natbitset” flows too smoothly to consider dreadful alternatives like “intbitset” or “posintbitset”...

Commit count: 36

cargo fmt