Hacker News new | ask | show | jobs
by antiframe 990 days ago
Rusts bounds checking is done at compile time, so you don't need to turn it off.
2 comments

Incorrect. Semantically, Rust always inserts runtime bounds-checks, regardless of optimization level. The compiler _may_ then remove them as part of an optimization pass, iff it can prove the check is redundant.

Do bounds checks even matter, even for very tight loops? This article [1] seems to suggest that removing the checks can give up to 10-15% speed increase under some circumstances. Worth it? I'd say no.

[1] https://dropbox.tech/infrastructure/lossless-compression-wit...

And runtime as well, like in any memory safe language.