3 ms·
While you are spot on with zero cost abstractions a bounds check in Rust is not without penalty (if enabled, should be off in release mode)
by atoav 7y ago
While you are spot on with zero cost abstractions a bounds check in Rust is not without penalty (if enabled, should be off in release mode)
- __s 7y agoBounds checks are always on. Integer overflow checks are disabled in release mode. Bounds checks are necessary for memory safety, whereas integer overflow isn't
- kjeetgill 7y agoI believe release mode keeps bound checks. It's integer overflow checks it gets rid of.
- jnordwick 7y agoyou can't turn bounds checking off. there are unsafe method for vec that allow you unchecked access to the array, but you need to to write it in unsafe block (some code that is performance sensitive does this).