Commit a689b2d
authored
Rollup merge of rust-lang#51312 - frewsxcv:clarify-hash-map-entry-get-mut, r=dtolnay
Clarify the difference between get_mut and into_mut for OccupiedEntry
The examples for both hash_map::OccupiedEntry::get_mut and
hash_map::OccupiedEntry::into_mut were almost identical. This led to some
confusion over the difference, namely why you would ever use get_mut when
into_mut gives alonger lifetime. Reddit thread:
https://www.reddit.com/r/rust/comments/8a5swr/why_does_hashmaps
This commit adds two lines and a comment to the example, to show that the
entry object can be re-used after calling get_mut.
Closes rust-lang#497452 files changed
+30
-4
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2369 | 2369 | | |
2370 | 2370 | | |
2371 | 2371 | | |
| 2372 | + | |
| 2373 | + | |
| 2374 | + | |
| 2375 | + | |
| 2376 | + | |
2372 | 2377 | | |
2373 | 2378 | | |
2374 | 2379 | | |
| |||
2380 | 2385 | | |
2381 | 2386 | | |
2382 | 2387 | | |
2383 | | - | |
| 2388 | + | |
| 2389 | + | |
| 2390 | + | |
| 2391 | + | |
| 2392 | + | |
2384 | 2393 | | |
2385 | | - | |
| 2394 | + | |
2386 | 2395 | | |
2387 | 2396 | | |
2388 | 2397 | | |
| |||
2391 | 2400 | | |
2392 | 2401 | | |
2393 | 2402 | | |
| 2403 | + | |
| 2404 | + | |
| 2405 | + | |
| 2406 | + | |
2394 | 2407 | | |
2395 | 2408 | | |
2396 | 2409 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2250 | 2250 | | |
2251 | 2251 | | |
2252 | 2252 | | |
| 2253 | + | |
| 2254 | + | |
| 2255 | + | |
| 2256 | + | |
| 2257 | + | |
2253 | 2258 | | |
2254 | 2259 | | |
2255 | 2260 | | |
| |||
2261 | 2266 | | |
2262 | 2267 | | |
2263 | 2268 | | |
2264 | | - | |
| 2269 | + | |
| 2270 | + | |
| 2271 | + | |
| 2272 | + | |
| 2273 | + | |
2265 | 2274 | | |
2266 | 2275 | | |
2267 | | - | |
| 2276 | + | |
2268 | 2277 | | |
2269 | 2278 | | |
2270 | 2279 | | |
| |||
2274 | 2283 | | |
2275 | 2284 | | |
2276 | 2285 | | |
| 2286 | + | |
| 2287 | + | |
| 2288 | + | |
| 2289 | + | |
2277 | 2290 | | |
2278 | 2291 | | |
2279 | 2292 | | |
| |||
0 commit comments