fixedbitset icon indicating copy to clipboard operation
fixedbitset copied to clipboard

FixedBitSet<K = usize> where K: From<usize> + Into<usize>

Open bestouff opened this issue 4 years ago • 2 comments

To use it as a drop-in replacement for HashSet, it would be nice to make FixedBitSet generic over its "index", i.e. FixedBitSet<K = usize> where K: From<usize> + Into<usize> (à la typed-index-collections).
So when you have e.g. a custom wrapper type MyId(u32) which is a HashSet<MyId>, and you know the collection is mainly dense (not too many holes), you could very easily switch to FixedBitSet<MyId> without changing anything else in the code.

bestouff avatar Oct 16 '21 20:10 bestouff

I made a PR but it's incompatible with const new(): https://github.com/rust-lang/rust/issues/57563

bestouff avatar Oct 25 '21 10:10 bestouff

See PR #69

bestouff avatar Oct 25 '21 12:10 bestouff

Not sure if this is a great idea due to the costs of monomorphization during compilation and the exposed generics as a part of it's type, which will need to show up in any associated type or generic type constraint. It's also possible to do this by wrapping FixedBitset in your own type as well.

james7132 avatar Apr 14 '24 21:04 james7132