2021-03-25 08:25:04 -05:00
|
|
|
error: usage of `contains_key` followed by `insert` on a `HashMap`
|
|
|
|
--> $DIR/entry.rs:16:5
|
|
|
|
|
|
|
|
|
LL | / if !m.contains_key(&k) {
|
|
|
|
LL | | m.insert(k, v);
|
|
|
|
LL | | }
|
|
|
|
| |_____^ help: try this: `m.entry(k).or_insert(v);`
|
|
|
|
|
|
|
|
|
= note: `-D clippy::map-entry` implied by `-D warnings`
|
|
|
|
|
|
|
|
error: usage of `contains_key` followed by `insert` on a `HashMap`
|
|
|
|
--> $DIR/entry.rs:20:5
|
|
|
|
|
|
|
|
|
LL | / if !m.contains_key(&k) {
|
|
|
|
LL | | if true {
|
|
|
|
LL | | m.insert(k, v);
|
|
|
|
LL | | } else {
|
|
|
|
LL | | m.insert(k, v2);
|
|
|
|
LL | | }
|
|
|
|
LL | | }
|
|
|
|
| |_____^
|
|
|
|
|
|
|
|
|
help: try this
|
|
|
|
|
|
2021-03-25 08:47:56 -05:00
|
|
|
LL | m.entry(k).or_insert_with(|| {
|
2021-03-25 08:25:04 -05:00
|
|
|
LL | if true {
|
2021-03-25 08:47:56 -05:00
|
|
|
LL | v
|
2021-03-25 08:25:04 -05:00
|
|
|
LL | } else {
|
2021-03-25 08:47:56 -05:00
|
|
|
LL | v2
|
2021-03-25 08:25:04 -05:00
|
|
|
LL | }
|
|
|
|
...
|
|
|
|
|
|
|
|
error: usage of `contains_key` followed by `insert` on a `HashMap`
|
|
|
|
--> $DIR/entry.rs:28:5
|
|
|
|
|
|
|
|
|
LL | / if !m.contains_key(&k) {
|
|
|
|
LL | | if true {
|
2021-03-25 08:47:56 -05:00
|
|
|
LL | | m.insert(k, v)
|
|
|
|
LL | | } else {
|
|
|
|
LL | | m.insert(k, v2)
|
|
|
|
LL | | };
|
|
|
|
LL | | }
|
|
|
|
| |_____^
|
|
|
|
|
|
|
|
|
help: try this
|
|
|
|
|
|
|
|
|
LL | m.entry(k).or_insert_with(|| {
|
|
|
|
LL | if true {
|
|
|
|
LL | v
|
|
|
|
LL | } else {
|
|
|
|
LL | v2
|
|
|
|
LL | }
|
|
|
|
...
|
|
|
|
|
|
|
|
error: usage of `contains_key` followed by `insert` on a `HashMap`
|
|
|
|
--> $DIR/entry.rs:36:5
|
|
|
|
|
|
|
|
|
LL | / if !m.contains_key(&k) {
|
|
|
|
LL | | if true {
|
2021-03-25 08:25:04 -05:00
|
|
|
LL | | m.insert(k, v);
|
|
|
|
LL | | } else {
|
|
|
|
... |
|
|
|
|
LL | | }
|
|
|
|
LL | | }
|
|
|
|
| |_____^
|
|
|
|
|
|
|
|
|
help: try this
|
|
|
|
|
|
|
|
|
LL | if let std::collections::hash_map::Entry::Vacant(e) = m.entry(k) {
|
|
|
|
LL | if true {
|
|
|
|
LL | e.insert(v);
|
|
|
|
LL | } else {
|
|
|
|
LL | e.insert(v2);
|
|
|
|
LL | return;
|
|
|
|
...
|
|
|
|
|
|
|
|
error: usage of `contains_key` followed by `insert` on a `HashMap`
|
2021-03-25 08:47:56 -05:00
|
|
|
--> $DIR/entry.rs:45:5
|
2021-03-25 08:25:04 -05:00
|
|
|
|
|
|
|
|
LL | / if !m.contains_key(&k) {
|
|
|
|
LL | | foo();
|
|
|
|
LL | | m.insert(k, v);
|
|
|
|
LL | | }
|
|
|
|
| |_____^
|
|
|
|
|
|
|
|
|
help: try this
|
|
|
|
|
|
2021-03-25 08:47:56 -05:00
|
|
|
LL | m.entry(k).or_insert_with(|| {
|
2021-03-25 08:25:04 -05:00
|
|
|
LL | foo();
|
2021-03-25 08:47:56 -05:00
|
|
|
LL | v
|
|
|
|
LL | });
|
2021-03-25 08:25:04 -05:00
|
|
|
|
|
|
|
|
|
|
|
|
error: usage of `contains_key` followed by `insert` on a `HashMap`
|
2021-03-25 08:47:56 -05:00
|
|
|
--> $DIR/entry.rs:50:5
|
2021-03-25 08:25:04 -05:00
|
|
|
|
|
|
|
|
LL | / if !m.contains_key(&k) {
|
|
|
|
LL | | match 0 {
|
|
|
|
LL | | 1 if true => {
|
|
|
|
LL | | m.insert(k, v);
|
|
|
|
... |
|
|
|
|
LL | | };
|
|
|
|
LL | | }
|
|
|
|
| |_____^
|
|
|
|
|
|
|
|
|
help: try this
|
|
|
|
|
|
2021-03-25 08:47:56 -05:00
|
|
|
LL | m.entry(k).or_insert_with(|| {
|
2021-03-25 08:25:04 -05:00
|
|
|
LL | match 0 {
|
|
|
|
LL | 1 if true => {
|
2021-03-25 08:47:56 -05:00
|
|
|
LL | v
|
2021-03-25 08:25:04 -05:00
|
|
|
LL | },
|
|
|
|
LL | _ => {
|
|
|
|
...
|
|
|
|
|
|
|
|
error: usage of `contains_key` followed by `insert` on a `HashMap`
|
2021-03-25 08:47:56 -05:00
|
|
|
--> $DIR/entry.rs:61:5
|
2021-03-25 08:25:04 -05:00
|
|
|
|
|
|
|
|
LL | / if !m.contains_key(&k) {
|
|
|
|
LL | | match 0 {
|
|
|
|
LL | | 0 => {},
|
|
|
|
LL | | 1 => {
|
|
|
|
... |
|
|
|
|
LL | | };
|
|
|
|
LL | | }
|
|
|
|
| |_____^
|
|
|
|
|
|
|
|
|
help: try this
|
|
|
|
|
|
|
|
|
LL | if let std::collections::hash_map::Entry::Vacant(e) = m.entry(k) {
|
|
|
|
LL | match 0 {
|
|
|
|
LL | 0 => {},
|
|
|
|
LL | 1 => {
|
|
|
|
LL | e.insert(v);
|
|
|
|
LL | },
|
|
|
|
...
|
|
|
|
|
|
|
|
error: usage of `contains_key` followed by `insert` on a `HashMap`
|
2021-03-25 08:47:56 -05:00
|
|
|
--> $DIR/entry.rs:73:5
|
2021-03-25 08:25:04 -05:00
|
|
|
|
|
|
|
|
LL | / if !m.contains_key(&k) {
|
|
|
|
LL | | foo();
|
|
|
|
LL | | match 0 {
|
|
|
|
LL | | 0 if false => {
|
|
|
|
... |
|
|
|
|
LL | | }
|
|
|
|
LL | | }
|
|
|
|
| |_____^
|
|
|
|
|
|
|
|
|
help: try this
|
|
|
|
|
|
2021-03-25 08:47:56 -05:00
|
|
|
LL | m.entry(k).or_insert_with(|| {
|
2021-03-25 08:25:04 -05:00
|
|
|
LL | foo();
|
|
|
|
LL | match 0 {
|
|
|
|
LL | 0 if false => {
|
2021-03-25 08:47:56 -05:00
|
|
|
LL | v
|
2021-03-25 08:25:04 -05:00
|
|
|
LL | },
|
|
|
|
...
|
|
|
|
|
|
|
|
error: usage of `contains_key` followed by `insert` on a `HashMap`
|
2021-03-25 08:47:56 -05:00
|
|
|
--> $DIR/entry.rs:99:5
|
2021-03-25 08:25:04 -05:00
|
|
|
|
|
|
|
|
LL | / if !m.contains_key(&m!(k)) {
|
|
|
|
LL | | m.insert(m!(k), m!(v));
|
|
|
|
LL | | }
|
2021-03-25 08:47:56 -05:00
|
|
|
| |_____^ help: try this: `m.entry(m!(k)).or_insert_with(|| m!(v));`
|
2021-03-25 08:25:04 -05:00
|
|
|
|
|
|
|
error: usage of `contains_key` followed by `insert` on a `BTreeMap`
|
2021-03-25 08:47:56 -05:00
|
|
|
--> $DIR/entry.rs:105:5
|
2021-03-25 08:25:04 -05:00
|
|
|
|
|
|
|
|
LL | / if !m.contains_key(&k) {
|
|
|
|
LL | | m.insert(k, v);
|
|
|
|
LL | | foo();
|
|
|
|
LL | | }
|
|
|
|
| |_____^
|
|
|
|
|
|
|
|
|
help: try this
|
|
|
|
|
|
|
|
|
LL | if let std::collections::btree_map::Entry::Vacant(e) = m.entry(k) {
|
|
|
|
LL | e.insert(v);
|
|
|
|
LL | foo();
|
|
|
|
LL | }
|
|
|
|
|
|
|
|
|
|
2021-03-25 08:47:56 -05:00
|
|
|
error: aborting due to 10 previous errors
|
2021-03-25 08:25:04 -05:00
|
|
|
|