]> git.lizzy.rs Git - rust.git/blob - tests/ui/entry_fixable.rs
Split map_entry tests into fixable and unfixable
[rust.git] / tests / ui / entry_fixable.rs
1 #![allow(unused, clippy::needless_pass_by_value)]
2 #![warn(clippy::map_entry)]
3
4 use std::collections::{BTreeMap, HashMap};
5 use std::hash::Hash;
6
7 fn foo() {}
8
9 fn insert_if_absent0<K: Eq + Hash, V>(m: &mut HashMap<K, V>, k: K, v: V) {
10     if !m.contains_key(&k) {
11         m.insert(k, v);
12     }
13 }
14
15 fn insert_other_if_absent<K: Eq + Hash, V>(m: &mut HashMap<K, V>, k: K, o: K, v: V) {
16     if !m.contains_key(&k) {
17         m.insert(o, v);
18     }
19 }
20
21 fn main() {}