OB_HM is Arc<Mutex<HashMap<...>>>
This caused the deadlock at very first iteration:
let mut OB_HM__:HashMap<u8, (f64, f64, f64, f64)> = HashMap::new();
for i in &p {
OB_HM__.insert(
*i,
(
OB_HM.lock().unwrap()[i].0, OB_HM.lock().unwrap()[i].1
R[&i].0,
R[&i].1
)
);
};
let mut OB_HM = OB_HM__;
And this solved it:
let mut OB_HM__:HashMap<u8, (f64, f64, f64, f64)> = HashMap::new();
for i in &p {
let x = OB_HM.lock().unwrap()[i].0;
let y = OB_HM.lock().unwrap()[i].1;
OB_HM__.insert(
*i,
(
x, y,
R[&i].0,
R[&i].1
)
);
};
let mut OB_HM = OB_HM__;
Why so? I had mere intuition but I need to understand the internals behind it. I'm guessing it has to do with how Rust creates tuples or how the method insert works?
And a side question about insert - why does it require ; EOL when it's the only instruction inside a loop?