|
|
|
|
|
by hoodedmongoose
4065 days ago
|
|
This is really exciting, and clearly more powerful than what you get in C/C++. That being said: >In a language like C++ there’s only once choice in this situation; that is to clone the vector. What about a shared_ptr to the vector? |
|
In Rust, when you have an immutable reference to a memory location, you know for certain that it won't be modified by distant code as long as you hold the reference. This guarantee also allows more compiler optimizations, because v[5] has the same value after a function call as before.