3 ms·
> I'm not a rust guy (I've only done hello world), but my understanding is it only gives you unique pointers Some very rough analogies: C++ : Rust
by loeg 2y ago
> I'm not a rust guy (I've only done hello world), but my understanding is it only gives you unique pointers
Some very rough analogies:
C++ : Rust
unique_ptr : Box
shared_ptr : Rc or Arc
references : references
- zozbot234 2y agoA C++ reference is more like a Rust &UnsafeCell<T> in practice - and there are thorny issues around the possibility of null references in C++ (which are supposed to be insta-UB per the C++ standard but are allowed by most compilers) that introduce additional questions about what the best mapping might be.
- School-Cotton 2y agoOne key difference between Rust smart pointers and C++ ones is that Rust ones can’t be null. So C++ unique_ptr is more like an Option<Box> that automatically calls unwrap_unchecked every time you try to use it.
- loeg 2y agoFair enough.