#![allow(unused, clippy::needless_pass_by_value, clippy::collapsible_if)]
#![warn(clippy::map_entry)]
-#![feature(asm)]
-use std::collections::{BTreeMap, HashMap};
+use std::arch::asm;
+use std::collections::HashMap;
use std::hash::Hash;
macro_rules! m {
if !m.contains_key(&k) {
insert!(m, k, v);
}
-}
-fn btree_map<K: Eq + Ord + Copy, V: Copy>(m: &mut BTreeMap<K, V>, k: K, v: V, v2: V) {
- // insert then do something, use if let
- if let std::collections::btree_map::Entry::Vacant(e) = m.entry(k) {
- e.insert(v);
- foo();
- }
+ // or_insert_with. Partial move of a local declared in the closure is ok.
+ m.entry(k).or_insert_with(|| {
+ let x = (String::new(), String::new());
+ let _ = x.0;
+ v
+ });
}
fn main() {}