3 ms·
Interesting observation. So one should instead do the comparison with something like: 1. if (x >= 0) && (x < arr_len(arr)) 2. get element from array
by est31 4y ago
Interesting observation. So one should instead do the comparison with something like:
1. if (x >= 0) && (x < arr_len(arr))
2. get element from array index x
3. else
4. core::hint::unreachable_unchecked
5. do more stuff
Where unreachable_unchecked transmits precisely such information to the optimizer: https://doc.rust-lang.org/stable/std/hint/fn.unreachable_unchecked.html https://doc.rust-lang.org/stable/std/hint/fn.unreachable_unc...