2021-09-08 09:31:47 -05:00
|
|
|
error: usage of `contains_key` followed by `insert` on a `BTreeMap`
|
2024-02-17 06:16:29 -06:00
|
|
|
--> tests/ui/entry_btree.rs:10:5
|
2021-09-08 09:31:47 -05:00
|
|
|
|
|
|
|
|
LL | / if !m.contains_key(&k) {
|
|
|
|
LL | | m.insert(k, v);
|
|
|
|
LL | | foo();
|
|
|
|
LL | | }
|
|
|
|
| |_____^
|
|
|
|
|
|
|
|
|
= note: `-D clippy::map-entry` implied by `-D warnings`
|
2023-08-01 07:02:21 -05:00
|
|
|
= help: to override `-D warnings` add `#[allow(clippy::map_entry)]`
|
2023-07-17 03:19:29 -05:00
|
|
|
help: try
|
2021-09-08 09:31:47 -05:00
|
|
|
|
|
|
|
|
LL ~ if let std::collections::btree_map::Entry::Vacant(e) = m.entry(k) {
|
|
|
|
LL + e.insert(v);
|
|
|
|
LL + foo();
|
|
|
|
LL + }
|
|
|
|
|
|
|
|
|
|
2023-11-21 11:08:42 -06:00
|
|
|
error: aborting due to 1 previous error
|
2021-09-08 09:31:47 -05:00
|
|
|
|