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

entry version w/ borrowed key #122

Closed
Licenser opened this issue Oct 12, 2019 · 3 comments
Closed

entry version w/ borrowed key #122

Licenser opened this issue Oct 12, 2019 · 3 comments

Comments

@Licenser
Copy link

Passing ownership of the key to the entry() function can be costly. Especially if then 'common' case is that an element is found this enforces cloning the key for every lookup.

What I would like is to propose a version of the entry function (so far I've not come up with a good name) that takes a a borrowed key and enforces that the ToOwned trait exists. This way the underlying structure can clone/own the key only when required.

I'm happy to make a PR for this but I wanted to discuss the option first to ensure there is interest, make sure that I didn't overlook something blocking, and to find a good and useful name.

@Amanieu
Copy link
Member

Amanieu commented Oct 12, 2019

Have you looked at the raw entry API in hashbrown?

@Licenser
Copy link
Author

I’ve not, so I’ll go and investigate that :D thanks for the pointer!

@Licenser
Copy link
Author

👍 solves what I was trying to do :D glad there is such a nice API :) I ported it to halfbrown too! Closing since with raw_entry there is really no need for an entry API w/ ref's/borrowed values. Thanks for pointing me in the right direction!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants