Skip to content

QQ: Why use &'b Q: Into<K> over Q: ToOwned<Owned = K> as EntryRef::insert trait bound? #660

@MrCroxx

Description

@MrCroxx

Hi. Thank you for paying attention to my (possibly silly) questions.

I'm using HashMap::entry_ref() and EntryRef::insert() APIs to try to reduce some clone overhead in my project. I found that the trait bound for EntryRef::insert() is &'b Q: Into<K>, rather than mostly used Q: ToOwned<Owned = K>. The &'b Q: Into<K> is a bit inconvenient to expose to the user since the primitives such as u64 hasn't implemented &u64: Into<u64>.

May I ask why this trait bound is used here? Thank you very much. 🙏

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions