mirror of
https://github.com/rust-lang/rust-clippy
synced 2024-11-18 10:48:36 +00:00
19 lines
366 B
Rust
19 lines
366 B
Rust
|
// 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() {}
|