-
Notifications
You must be signed in to change notification settings - Fork 321
Specify hasher for unique? #462
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
Comments
I could imagine that some users want to check uniqueness with more efficient containers, but shouldn't we at least think about generalizing a bit more so that users can essentially specify a container that can insert an element, returning if the element already has been in there or not (such as |
I don't know how it could be that generic. There's always |
It would be a bit of work, but I imagine one could e.g. define a trait that encapsulates inserting an element into the container and - in the same method - returning if the element was already present. This trait could then be implemented for |
What's wrong with just using HashMap as is? |
Nothing per se - it just struck me that if a user wants to specify a custom hasher, they might as well want something else. But without trying I confess that generalizing this could well result in too much work to be worth it. |
Would there be interest in adding a variant of
unique
which allows you to specify the hasher? How about the nameunique_default
? The name isn't great but it's the best I can think of. It is inspired byHashMap
which allows you to specify the hasher usingHashMap::default()
.Example:
I have implemented this on my machine but I want to get feedback before opening a PR.
The text was updated successfully, but these errors were encountered: