Skip to content

Add HashMap.entry_or_clone() method #1203

Open
@dnspies

Description

Sometimes I have a key type which implements Clone, but for efficiency reasons I don't want to clone it unless it's absolutely necessary.

In this case it would be nice to have a method

my_hash_map.entry_or_clone(&k)

which behaves identically to

my_hash_map.entry(k.clone())

but only bothers to clone k if the key doesn't already exist in my_hash_map.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    T-libs-apiRelevant to the library API team, which will review and decide on the RFC.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions