|
|
|
|
|
by FartyMcFarter
2165 days ago
|
|
> Just like with array access, the compiler can often optimize the checks away, making the safe and unsafe versions equivalent when the compiler can prove it. Can it "often" solve the halting problem as well? The hope that this kind of optimization will happen sounds a bit fanciful for any non-trivial part of a program. |
|
I ported a small C function to Rust recently that involved some looping, and all of the bounds checking was completely eliminated, even once I took the line-by-line port and turned it into a slightly higher level one with slices and iterators instead of pointer + length.