]> git.lizzy.rs Git - rust.git/commit
Clarify the difference between get_mut and into_mut for OccupiedEntry
authorPhlosioneer <mattmdrr2@gmail.com>
Fri, 6 Apr 2018 19:32:54 +0000 (15:32 -0400)
committerCorey Farwell <coreyf@rwell.org>
Sat, 2 Jun 2018 19:51:39 +0000 (15:51 -0400)
commit1bc6c4b10e7036be6fe61999fabf3462eeed39be
tree1696cd63f6c7acdca92cb7cded87a7b195ef1d06
parent4ecf12bf0eb8386626ccdb5f721a7183ccc4eba6
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.
src/libstd/collections/hash/map.rs