2 ms·
Note that Rust has unchecked index, you just have to explicitly ask for that if you want it. You can even - if you just insist on writing cursed code - which it
by tialaramex 5y ago
Note that Rust has unchecked index, you just have to explicitly ask for that if you want it. You can even - if you just insist on writing cursed code - which it seems jcelerier is, write your own type in which the index is always unchecked and it is Undefined Behaviour when you inevitably make a mistake. Just implement std::ops::Index and if you also want to mutate these probably invalid indices, std::ops::IndexMut and in your implementation say you're unsafe and just don't bother doing bounds checks.
You can shoot yourself in the foot with Rust, it's just that you need to explicitly point a loaded gun at your foot and pull the trigger, whereas C++ feels like any excuse to shoot you in the foot is just too tempting to ignore even if you were trying pretty hard not to have that happen.
- pjmlp 5y agoC++ devs that actually care about security the same way as titzer, do turn on the security checks that are disabled by default, thus you can have a same experience. Example, on Visual Studio define _ITERATOR_DEBUG_LEVEL to 1, enable /analize as part of the build. While not Rust like, it is already much better than not caring.