summaryrefslogtreecommitdiffstats
path: root/src/tools/clippy/tests/ui/entry_btree.fixed
blob: 94979104556bc882267d230b41c535319d712bd8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
// run-rustfix

#![warn(clippy::map_entry)]
#![allow(dead_code)]

use std::collections::BTreeMap;

fn foo() {}

fn btree_map<K: Eq + Ord + Copy, V: Copy>(m: &mut BTreeMap<K, V>, k: K, v: V) {
    // insert then do something, use if let
    if let std::collections::btree_map::Entry::Vacant(e) = m.entry(k) {
        e.insert(v);
        foo();
    }
}

fn main() {}