Guess the language by the error
Jan. 14th, 2020 04:37 pm:-) Gosh, the gift that just keeps giving
Walk the dependencies BTreeMap<u64, Vec<u64>>:
Walk the dependencies BTreeMap<u64, Vec<u64>>:
let mut clazz_walk = clazz_dep.get(&0).unwrap().clone();
let mut looked_at = 0;
while !clazz_walk.is_empty() {
looked_at += 1;
let dep_id = clazz_walk.pop().unwrap();
let super_class = clazz_map.get(&dep_id).unwrap();
if let Some(super_deps) = clazz_dep.get(&dep_id) {
for sub_class in super_deps {
clazz_walk.push(*sub_class);
let sub = clazz_map.get_mut(&sub_class).unwrap();
for idx in super_class.id_idx.iter() {
sub.id_idx.push(idx + sub.instance_sz);
}
sub.instance_sz += super_class.instance_sz;
}
}
}
error[E0502]: cannot borrow `clazz_map` as mutable because it is also borrowed as immutable
--> src/main.rs:493:23
|
489 | let super_class = clazz_map.get(&dep_id).unwrap();
| --------- immutable borrow occurs here
...
493 | let sub = clazz_map.get_mut(&sub_class).unwrap();
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ mutable borrow occurs here
494 | for idx in super_class.id_idx.iter() {
| ------------------ immutable borrow later used here