Open coderboyisongithub opened 2 months ago
@rustbot label -needs-triage +C-discussion +A-borrow-checker
An example of why it won't work:
let iterator = vector.iter(); // immutable reference
vector.push(something); // mutable reference
// The vector could have re-allocated memory at this point, what does iterator look at?
I think there is no issue with allowing one mutable reference with any number of immutable references in single scope.Having single mutable reference ensure there is one and only one mutator, while all immutable reference can yet access the mutated information from the variable.