rust-clippy/tests/ui/entry_btree.fixed
2023-08-11 14:02:28 +00:00

16 lines
350 B
Rust

#![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() {}