2 ms·
>What surprises me a little though is that there is zero memory error even in unsafe Rust. There has to be some unsafe code somewhere, for low level data struct
by carlmr 4y ago
>What surprises me a little though is that there is zero memory error even in unsafe Rust. There has to be some unsafe code somewhere, for low level data structures and things like that.
Even unsafe Rust has more strict typing and borrow checking which C++ doesn't have. It does allow raw pointers, but it's still safer than C++.
The other thing is that if say 1% of your loc is unsafe Rust, it's much easier to put this under more scrutiny than the whole C++ codebase.
And 1% is a lot if you ask me. I almost never need unsafe at all.
>There has to be some unsafe code somewhere, for low level data structures and things like that.
In most cases you can just use the standard library code for these. They do contain unsafe of course, but it's in one of the most battle tested places.