Hacker News new | ask | show | jobs
by est31 1302 days 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_unc...