I'm really going super slow and very careful with this project. I see how even small step can cause the borrow checker to complain. How can I share the same struct with multiple functions and run operations on it?
let system = System {
x: HashMap::new(),
};
fn a(system:&System) {
let System { mut x, .. } = system;
// add something to x
}
fn b(system:&System) {
let System { mut x, .. } = system;
// do stuff on x
}
a(&system)
b(&system)
error I'm getting
let System { &mut x, .. } = system;
| ------ ^ expected identifier
| |
| while parsing the fields for this pattern
or
38 | let System { mut x, .. } = system;
| ---------- ^^^^^^
| |
| data moved here
| move occurs because `broker` has type `HashMap<String, Y>`, which does not implement the `Copy` trait