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
added get_or_insert_with function #718
Conversation
Thanks! Could you add a test for the case where the closure panics? (related #717) |
…ere closure panics.
I have added two test cases - (a) for valid case (b) where closure panics. Please check if this is what you are looking at. Thanks |
@taiki-e - pls update here. |
Also, it would make sense to add the same method to SkipMap |
As suggested by taiki-e Co-authored-by: Taiki Endo <te316e89@gmail.com>
…n case another thread writes before. 2) Added test case for the same.
Sure, will do. |
2) Added corresponding test case for SkipMap
@taiki-e - added corresponding method and test for SkipMap. For SkipSet, as value is always () it may not make sense. Please review. Thanks |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. Thanks @snow01!
bors r+
Build succeeded: |
get_or_insert_with function allows lazy creation of default value. Default values may be heavy objects, lazy creation doesn't create un-necessary objects when key is already there in the data structure.