Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
bestouff opened this issue Oct 16, 2021 · 3 comments
Closed

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

bestouff opened this issue Oct 16, 2021 · 3 comments

Comments

@bestouff
Copy link

bestouff commented Oct 16, 2021

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 bestouff changed the title Make FixedBitSet generic FixedBitSet<K = usize> where K: From<usize> + Into<usize> Oct 16, 2021
@bestouff
Copy link
Author

I made a PR but it's incompatible with const new(): rust-lang/rust#57563

@bestouff
Copy link
Author

See PR #69

@james7132
Copy link
Collaborator

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 james7132 closed this as not planned Won't fix, can't repro, duplicate, stale Apr 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants