adds value-wrapper for borrowed or owned return values#177
Open
behzadnouri wants to merge 2 commits intojeromefroe:masterfrom
Open
adds value-wrapper for borrowed or owned return values#177behzadnouri wants to merge 2 commits intojeromefroe:masterfrom
behzadnouri wants to merge 2 commits intojeromefroe:masterfrom
Conversation
NonZeroUsize for capacity is very nonergonomic and prevents some use-cases. For example a usize allows to disable caching by using capacity zero. see: jeromefroe#165 This reverts commit 0e415ef.
get_or_insert, get_or_insert_mut and try_get_or_insert may return None
only in the case where capacity is zero.
Instead this commit adds a ValueWrapper:
enum ValueWrapper<'a, V> {
Borrowed(&'a V),
Owned(V),
}
which makes it possible for these methods to always return a value which
can be borrowed as V.
Author
|
@jeromefroe This will address the discussion here: #165 (comment) cc @Yosi-Hezi |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
get_or_insert,get_or_insert_mutandtry_get_or_insertmay returnNoneonly in the case where capacity is zero.Instead this commit adds a
ValueWrapper:which makes it possible for these methods to always return a value which can be borrowed as V.