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

Feature request: into_group_btreemap #520

Open
HollayHorvath opened this issue Jan 25, 2021 · 3 comments
Open

Feature request: into_group_btreemap #520

HollayHorvath opened this issue Jan 25, 2021 · 3 comments
Labels
generic-container Generic vector/hasher/map

Comments

@HollayHorvath
Copy link

A BTreeMap version of the into_group* function group would be a nice addition.

The idea is that sometimes working with Hash is not feasible or even impossible, e.g. when you have to work with float-based datatypes as key or you would like to group your data by some custom criteria without wrapping the type and implementing custom Hash.

The into_group_btreemap() and into_group_btreemap_by() functions should work similarly how into_group_map() and into_group_btreemap_by() work, but would require K: Ord + Eq instead of K: Hash + Eq and would return BTreeMap<K, Vec<V>> instead of HashMap<K, Vec<V>>.

I have the code patched into my codebase, so I can also start a PR is this feature is required.

@phimuemue
Copy link
Member

phimuemue commented Jan 25, 2021

Hi, nice idea. It appears there is a certain need for this, as the request for other containers comes up (in different flavors) from time to time:

I'd like to put on the record (see #462 (comment)) that imho in an ideal world we would solve this problem by abstracting over the kind of the container -- leading to uniform support for HashMaps, BTreeMaps, sorted Vecs, EnumMap<Enum, Option<_>>, and possibly more, instead of having sporadic support for some of them.

It might not be easily doable, but I am unsure if duplicating functions here and there is better than exploring the possibilities of the aforementioned abstraction.

@Philippe-Cholet Philippe-Cholet added the generic-container Generic vector/hasher/map label Jan 25, 2024
@loarca
Copy link

loarca commented Feb 9, 2024

Hey 👋🏻

Any updates on this?

@Philippe-Cholet
Copy link
Member

I did not see any update related to it. The only recent thing is me adding the label "generic-container".
Personally, I tried some approaches to have more generic containers but nothing satisfying yet (by far).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
generic-container Generic vector/hasher/map
Projects
None yet
Development

No branches or pull requests

4 participants