4 ms·
Rust's ownership model tracks the safety of borrows at compile time in ways C++ can't. You can derive a reference from another reference, and the compiler won't
by firethief 7y ago
Rust's ownership model tracks the safety of borrows at compile time in ways C++ can't. You can derive a reference from another reference, and the compiler won't let you do anything to the original object that would leave the derived reference dangling. In C++ there are two different conventions for that: use plain old pointers to represent the borrows, and be careful they don't outlive the owning `unique_ptr`; or use `shared_ptr` to do the bookkeeping at runtime (also available in Rust, as Rc/Arc).
- codesushi42 7y agoGot it, thanks for the explanation. So C++ programmers are able to subvert the upfront complexity by ignoring C++ 11 features then, going straight to raw pointers.