3 ms·
These guidelines pretty much apply to C++, although pointers in Rust are more akin to smart pointers than raw pointers, and there are indeed a bunch of use case
by fhd2 13y ago
These guidelines pretty much apply to C++, although pointers in Rust are more akin to smart pointers than raw pointers, and there are indeed a bunch of use cases for those. Sticking to values and references works pretty well most of the time though.
But pointers in Rust seem pretty well thought out and more sophisticated than what's possible in C++. I'm particularly excited about the compiler error when a borrowed pointer goes out of scope.
- steveklabnik 13y agoYup! If you use C++, this wiki page can help: https://github.com/mozilla/rust/wiki/Rust-for-CXX-programmers https://github.com/mozilla/rust/wiki/Rust-for-CXX-programmer... Basically, imagine boost's pointer types being in the language, so that the compiler can reason about them.
- fhd2 13y agoI love it. I'm staring to look for reasons to try Rust in a project, luckily they're piling up :)
- steveklabnik 13y agoSupposedly 1.0 is "around the corner," so maybe you'll find a good reason by then...
- pjmlp 13y ago> These guidelines pretty much apply to C++ Yep, C suffers from pointer abuse and with it, infects any language that uses C compatibility as language subset.