Rust cannot borrow as mutable: what each error means and how to fix it
Rust's "cannot borrow as mutable" message covers several different mistakes, and each one has a different fix. Start with the error code. E0596 means the value was never mutable in the first place. E0502 means a shared borrow is still alive when you try to mutate. E0499 means you…