It certainly feels like a failure of the Rust type system that you cannot have multiple mutating references to the same variable when the variable is accessed only from a single thread. I know the reason for this is to prevent iterator invalidation, but this is too blunt of an instrument.
Iterator invalidation (as it's known in C++) is a risk to memory safety only when some of the memory that is accessible through an iterator (or a reference) is deallocated. A better type system would make a distinction between those expressions that may deallocate and those that cannot. Then, when multiple mutating references pointed to the same variable, the compiler would disallow only the use of the potentially deallocating expressions through those references. If a variable may be accessed concurrently from multiple threads, only then would the current "no mutating references allowed to that variable" -rule be enforced. Sorry for the brevity, I'm writing this from a phone and I haven't thought of this issue very thoroughly. _______________________________________________ Rust-dev mailing list [email protected] https://mail.mozilla.org/listinfo/rust-dev
