2021-09-08 14:31:47 +00:00
|
|
|
error: usage of `contains_key` followed by `insert` on a `BTreeMap`
|
2023-08-24 19:32:12 +00:00
|
|
|
--> $DIR/entry_btree.rs:10:5
|
2021-09-08 14:31:47 +00: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 12:02:21 +00:00
|
|
|
= help: to override `-D warnings` add `#[allow(clippy::map_entry)]`
|
2023-07-17 08:19:29 +00:00
|
|
|
help: try
|
2021-09-08 14:31:47 +00:00
|
|
|
|
|
|
|
|
LL ~ if let std::collections::btree_map::Entry::Vacant(e) = m.entry(k) {
|
|
|
|
LL + e.insert(v);
|
|
|
|
LL + foo();
|
|
|
|
LL + }
|
|
|
|
|
|
|
|
|
|
|
|
|
error: aborting due to previous error
|
|
|
|
|