3 ms·
> Rust [...] achieves this particular feature mostly through runtime checks If you do a 1:1 translation then sure. But idiomatic rust probably uses zero-overhe
by jjnoakes 10y ago
> Rust [...] achieves this particular feature mostly through runtime checks
If you do a 1:1 translation then sure. But idiomatic rust probably uses zero-overhead (or very nearly so, I haven't checked in a while) iterators and other higher level constructs that generate extremely efficient code and don't require bounds checks.
You won't see nearly as many "for (size_t i = 0; i < BOUND; i++) { ... array[i] ...}" in Rust, which means even though array bounds checking might be no faster in Rust, the fact that you don't use it as often is a big win.