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

Implement inserting items into FrozenMap with a callback function. #49

Closed
wants to merge 1 commit into from

Conversation

alvra
Copy link

@alvra alvra commented Jul 20, 2023

This feature supports the use case where creating the item is expensive and can be omitted in case it's not in the map yet.

// these should never return &K or &V
// these should never delete any entries
pub fn insert(&self, k: K, v: V) -> &V::Target {
pub fn insert_with(&self, k: K, v: impl FnOnce() -> V) -> &V::Target {
Copy link
Owner

@Manishearth Manishearth Jul 25, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please update the safety comment on in_use to mention the insert_with callback in addition to eq etc

@Manishearth
Copy link
Owner

Actually, I'm not going to merge this for now: To fix #48 I may end up encapsulating the map differently; and a very nice property that comes out of that is that I may no longer need a reentrancy guard. But that makes this function illegal. So I'm going to hold off on merging this.

@alvra
Copy link
Author

alvra commented Jul 30, 2023

Ok, thanks for your response

@Manishearth
Copy link
Owner

May reopen based on how we resolve #48

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

Successfully merging this pull request may close these issues.

2 participants