You can use iterators to avoid unnecessary bounds checking on every element in a slice and you can still get an index to the value. Something like this:
``` for (i, val) in my_slice.iter().enumerate() { let x = *val + 9999; } ```
``` for (i, val) in my_slice.iter().enumerate() { let x = *val + 9999; } ```
I mean maybe? But I probably wouldn't anyway for this case as a slice reference is actually a "fat" pointer (ie twice the size of a normal pointer) and the length of the slice won't be used (the block size is known per kernel); LLVM might delete the length part anyway.
These are automatically generated kernels, so readability isn't the primary concern here.