Hi, I need a register over some named complex data. I use a hash map for that so I can easily fetch the data by name.
During runtime new data can be added, data can never be removed.
A simplification of the problem is this:
let mut map = HashMap::new();
map.insert(0, "value".to_owned());
// Get reference (immutable borrow)
let reference = map.get(&0).unwrap();
// Insert value to hashmap (mutable borrow, not possible)
map.insert(1, "value2".to_owned());
println!("{:?}", reference);
Here is a little bigger example to get the whole context:
Is it possible to circumvent this check somehow?
I will never modify data in the hashmap, only add to it.