4 ms·
There are many differences when it comes to safety: - Like you said, Rust doesn't let you data race on the contents of an Arc. - Rust also doesn't let you dat
by oconnor663 4y ago
There are many differences when it comes to safety:
- Like you said, Rust doesn't let you data race on the contents of an Arc.
- Rust also doesn't let you data race on the Arc itself (i.e. repointing a global Arc without synchronization). This is Bug #5 in this great talk: https://youtu.be/lkgszkPnV8g https://youtu.be/lkgszkPnV8g
- Rust also doesn't let you retain a reference to the contents of an Arc longer than you retain the Arc. This is the bug that C++ Core Guideline R.37 is about: http://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines#Rr-smartptrget http://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines#...
But I'm not sure I'd call these Arc vs shared_ptr differences per se, because almost any comparison between a Rust container and its C++ equivalent looks similar.