chiark / gitweb /
Clippy fix: borrow the HashMap Entry we want to insert into.
authorSimon Tatham <anakin@pobox.com>
Fri, 5 Jan 2024 23:31:21 +0000 (23:31 +0000)
committerSimon Tatham <anakin@pobox.com>
Sat, 6 Jan 2024 09:18:31 +0000 (09:18 +0000)
commiteeec8d323894d9015b586a94db7497c2080be8c2
tree4b4848878f9b7457e70d682657a6cff55ec3a886
parentb79aecad29ed78d6dfc511bf33e6238e987dfdbc
Clippy fix: borrow the HashMap Entry we want to insert into.

I hadn't known about this method of HashMap at all: you can test
whether a key exists, in such a way that you also get a reference to
the slot you'd want to insert it into if it didn't. Then you don't
need the two hash lookups you would with the more obvious approach of
separately testing for contains_key and then maybe inserting.
src/file.rs