feat: add return val to replace_bucket_with replace_entry_with
#419
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.
If a user has a
RawOccupiedEntryMut, they should be able to usereplace_entry_withto conditionally remove it. However, if a user wishes to extract data from this entity during the removal process, the current api necessitates the use ofunwrap:This is because while
Fis bounded byFnOnce, it is under no obligation to call it, which in this example means there is no guarnatee thatcoolnessis initialized. This proposed change introduces a new return valueRwhich allows callers to transport this data out ofF. Notably it also commits thereplace_entry_withto callingF, since there is no other way to generate anR. With this, our example becomes:An alternative to this change is to introduce a new API with a new name instead of modifying the existing one as this is a breaking change.