How else would you implement C++’s vector::operator[] for example?
This to me is the clearest example of something that’s safe in Rust, and impossible to make safe in C++.
This to me is the clearest example of something that’s safe in Rust, and impossible to make safe in C++.
Are you asking in a theoretical world where it isn’t defined to already return a `T&`?
My overall advice here would be that if you find yourself implementing vector-like data structures very often, then it is time to take a second look the design.