3 ms·
If the constructor here would take a const reference, it would have the same problem (the existence of a const reference doesn't preclude non-const references t
by taejo 3y ago
If the constructor here would take a const reference, it would have the same problem (the existence of a const reference doesn't preclude non-const references to the same object). If it took an argument by value, it wouldn't make a difference whether it was const or not, because no other thread could have access to the same object, because it would be copied.
In Rust, on the other hand, if there's a mutable reference to an object, there can be no other references to the same object at the same time.