about summary refs log tree commit diff
path: root/src/test/codegen/src-hash-algorithm
diff options
context:
space:
mode:
authorChai T. Rex <ChaiTRex@users.noreply.github.com>2020-04-10 12:10:05 -0400
committerChai T. Rex <ChaiTRex@users.noreply.github.com>2020-04-10 12:54:09 -0400
commit921579cc3cdc57dbcfac48b275d92b7927234988 (patch)
tree51cc908210688838c34c306d2d955a0870088095 /src/test/codegen/src-hash-algorithm
parent93dc97a85381cc52eb872d27e50e4d518926a27c (diff)
downloadrust-921579cc3cdc57dbcfac48b275d92b7927234988.tar.gz
rust-921579cc3cdc57dbcfac48b275d92b7927234988.zip
Add or_insert_with_key to Entry of HashMap/BTreeMap
Going along with or_insert_with, or_insert_with_key provides the
Entry's key to the lambda, avoiding the need to either clone the
key or the need to reimplement this body of this method from
scratch each time.

This is useful when the initial value for a map entry is derived
from the key. For example, the introductory Rust book has an
example Cacher struct that takes an expensive-to-compute lambda and
then can, given an argument to the lambda, produce either the
cached result or execute the lambda.
Diffstat (limited to 'src/test/codegen/src-hash-algorithm')
0 files changed, 0 insertions, 0 deletions