Re:Garbage collected smart pointers in Rust via concurrent c...
by zozbot234 on Friday December 13, 2024 @06:03PM
(#42413131)
A 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.
Re:Garbage collected smart pointers in Rust via concurrent c...
by umanwizard on Friday December 13, 2024 @10:32PM
(#42414472)
One 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.
Some very rough analogies: