mirror of
https://github.com/rust-lang/rust-clippy
synced 2024-12-04 18:40:18 +00:00
4838c78ba4
Locals which can be partially moved created within the to-be-created closure shouldn't block the use of a closure
20 lines
482 B
Text
20 lines
482 B
Text
error: usage of `contains_key` followed by `insert` on a `BTreeMap`
|
|
--> $DIR/entry_btree.rs:12: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: try this
|
|
|
|
|
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
|
|
|