Uh oh!
There was an error while loading. Please reload this page.
Addressed issues raised in #44286. (OccupiedEntry::replace_entry) - #45152
Conversation
rust-highfive
commented
Oct 9, 2017
Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @dtolnay (or someone else) soon. If any changes to this PR are deemed necessary, please add them as extra commits. This ensures that the reviewer can see what has changed since they last reviewed the code. Due to the way GitHub handles out-of-date commits, this should also make it reasonably obvious what issues have or haven't been addressed. Large or tricky changes may require several passes of review and changes. Please see the contribution instructions for more information. |
OccupiedEntry::replace_entry)There was a problem hiding this comment.
Please change the tabs into spaces.
[00:04:04] tidy error: /checkout/src/libstd/collections/hash/map.rs:2289: tab character
[00:04:04] tidy error: /checkout/src/libstd/collections/hash/map.rs:2290: tab character
aidanhs
commented
Oct 19, 2017
Ping @dtolnay for review! (also pinged on IRC) |
dtolnay
left a comment
There was a problem hiding this comment.
Thanks for the reminder!
I am on board with the idea, and the implementation looks good. But could you change the usage example to illustrate a more realistic use case? Replacing "poneyland".to_string() with "poneyland".to_string() is not meaningful.
In general, usage examples are often not about how to use a particular API. If the user got far enough with Rust to be looking at OccupiedEntry documentation, we can assume they understand how to match on an enum and invoke functions. Here and elsewhere, the role of the example should be about why someone would want this functionality.
Either here or in a following PR, please also update the replace_entry documentation with a why example.
carols10cents
commented
Oct 30, 2017
Binero
commented
Oct 30, 2017
@dtolnay@carols10cents Oh, whoops. I missed this one. It sure does. As for Discussion: #44286 |
stepancheg
commented
Oct 30, 2017
It can be used for example to reclaim memory used by keys. E. g. |
shepmaster
commented
Nov 10, 2017
Triage ping @Binero! It looks like you got some feedback on the rationale for |
This commit renames the `replace` function to `replace_entry`, and creates a seperate `replace_key` function for `OccupiedEntry`. The original `replace` function did not solve the use-case where the key needed to be replaced, but not the value. Documentation and naming has also been updated to better reflect what the original replace function does.
Added better examples, and rebased them all. |
dtolnay
commented
Nov 11, 2017
@bors r+ |
bors
commented
Nov 11, 2017
📌 Commit 3ba2631 has been approved by |
bors
commented
Nov 11, 2017
⌛ Testing commit 3ba26319996e3d1d8a6594a80e3ab0acb89ade66 with merge 5120f57e5210955682db123cfb4a23d12143f80e... |
bors
commented
Nov 11, 2017
💔 Test failed - status-appveyor |
dtolnay
commented
Nov 11, 2017
|
The current examples should be more realistic.
Binero
commented
Nov 11, 2017
Amended the style-changes to the last commit. |
dtolnay
commented
Nov 11, 2017
@bors r+ |
bors
commented
Nov 11, 2017
📌 Commit 0fb37fc has been approved by |
bors
commented
Nov 11, 2017
Addressed issues raised in #44286. (`OccupiedEntry::replace_entry`) This commit renames the `replace` function to `replace_entry`, and creates a seperate `replace_key` function for `OccupiedEntry`. The original `replace` function did not solve the use-case where the key needed to be replaced, but not the value. Documentation and naming has also been updated to better reflect what the original replace function does.
bors
commented
Nov 11, 2017
☀️ Test successful - status-appveyor, status-travis |
Closesrust-lang#27078. Closesrust-lang#27985. Closesrust-lang#39848. Closesrust-lang#42164. Closesrust-lang#42479. Closesrust-lang#45152. Closesrust-lang#45662. Closesrust-lang#45876. Closesrust-lang#45965.
This commit renames the
replacefunction toreplace_entry, andcreates a seperate
replace_keyfunction forOccupiedEntry. Theoriginal
replacefunction did not solve the use-case where thekey needed to be replaced, but not the value. Documentation and
naming has also been updated to better reflect what the original
replace function does.