rust-clippy/tests/ui/entry_btree.fixed
Jason Newcomb 4838c78ba4
Improve manual_map and map_entry
Locals which can be partially moved created within the to-be-created closure shouldn't block the use of a closure
2021-08-14 19:49:45 -04:00

18 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() {}