Skip to content

Fix Borrow #2433

@SoniEx2

Description

@SoniEx2

std::borrow::Borrow has an extremely limited API, making the following painful:

struct Thing (u8, String);
let m: HashMap<Thing, String> = Default::default();
// how to access m with u8, &str, avoiding allocations?

I recommend changing Borrow into Borrow<'a, T> so you can do Borrow<'a, &'a str> for String and derive it for multifield structs and stuff, reducing allocations all over the place.

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