Skip to content

Make grouping maps container agnostic #605

Open
@farnoy

Description

@farnoy

Could we make the grouping operations generic so they're able to produce collections other than std::collections::HashMap?

I'm proposing turning

    fn into_group_map<K, V>(self) -> HashMap<K, Vec<V>>

into

    fn into_group_map<K, V, C>(self) -> C where C: FromIterator<(K, Vec<V>)>

And similarly with into_grouping_map() and that family of types.

My use case is to directly produce HashMaps from the hashbrown crate and not std, but this should enable different applications as well.

Since the HashMap itself is a key component of how the grouping is achieved, it's probably insufficient to use FromIterator (we don't want to allocate an intermediate collection). I want to start a conversation and see what others think.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions