| Crates.io | natbitset |
| lib.rs | natbitset |
| version | 0.2.0 |
| created_at | 2026-01-21 22:42:31.731262+00 |
| updated_at | 2026-01-24 16:50:43.082666+00 |
| description | A lightweight set implementation for consecutive natural numbers |
| homepage | |
| repository | https://github.com/Sup2point0/natbitset |
| max_upload_size | |
| id | 2060269 |
| size | 32,856 |
A super-lightweight set implementation for consecutive natural numbers 1..=N.1
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!
View the Changelog in the GitHub repository.
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”... ↩