mirror of
https://github.com/rust-lang/rust-clippy
synced 2024-12-24 03:53:20 +00:00
c2c73189c8
Co-authored-by: Adrian <adrian.iosdev@gmail.com>
21 lines
550 B
Text
21 lines
550 B
Text
error: usage of `contains_key` followed by `insert` on a `BTreeMap`
|
|
--> $DIR/entry_btree.rs:10:5
|
|
|
|
|
LL | / if !m.contains_key(&k) {
|
|
LL | | m.insert(k, v);
|
|
LL | | foo();
|
|
LL | | }
|
|
| |_____^
|
|
|
|
|
= note: `-D clippy::map-entry` implied by `-D warnings`
|
|
= help: to override `-D warnings` add `#[allow(clippy::map_entry)]`
|
|
help: try
|
|
|
|
|
LL ~ if let std::collections::btree_map::Entry::Vacant(e) = m.entry(k) {
|
|
LL + e.insert(v);
|
|
LL + foo();
|
|
LL + }
|
|
|
|
|
|
|
error: aborting due to 1 previous error
|
|
|