by Ygg2 · 4y ago · 0 comments
And random access `array[intval]` will always be performance crippled if intval is provided by external system at runtime.
Even if intval is guaranteed to be between 0..<array.length, you need to converted it to that type.
What I want is a check outside of the loop then every access inside a loop unchecked and fast. Which isn't what rust does. Then it throws your memory away if you did an oops and went out of bounds
That's exactly what iterators allow.
I tend to treat iterators as a non-factor when discussing semantics of a language as I will always default to them not being a 'language-level' construct. I am not a fan of iterators in any case, but then again, I don't particularly like any higher level constructs in my 'run-time' code.
* https://github.com/mike-barber/rust-zero-cost-abstractions
* https://carette.xyz/posts/zero_cost_abstraction/
* https://ruudvanasseldonk.com/2016/11/30/zero-cost-abstractio...
> What I want is a check outside of the loop then every access inside a loop unchecked and fast
That's what Iterators give you.