bit_combi_iter
bit_combi_iter is a small dependency-free crate to enumerate all bit combinations less than given unsigned integer value
keeping 1s in the bits.
use BitCombinations;
This crate is useful when you want to enumerate all n bit integers including k ones.
// Enumerate all 5 bit integers including 3 ones (as u8)
new
// 11100
// 11010
// 11001
// 10110
// 10101
// ...
Install
Add this crate to dependencies in your Cargo.toml.
[]
= "1"
Document
See the API document.
Special Thanks
The algorithm was borrowed from the blog post by @herumi.
License
Distributed under the MIT License.