3 ms·
I'm not a Rust programmer, but AFAIK Rust has inline functions, so if your code has lots of indexing calls, could most of the pain go away with a few short help
by piaste 5y ago
I'm not a Rust programmer, but AFAIK Rust has inline functions, so if your code has lots of indexing calls, could most of the pain go away with a few short helper functions?
#[inline(always)]
fn idx(i : u32) { usize::try_from(i).unwrap() }
or
#[inline(always)]
fn get(arr: [T], i : u32) { arr.[usize::try_from(i).unwrap()] }
Have to repeat the definition for each numeric type you use, I guess, but hopefully you aren't using _that_ many of them.