3 ms·
"Rust essentially never wastes cycles on bounds checking thanks to the design of its iterators." Can you explain this or point me to the relevant documentation
by captaincrowbar 11y ago
"Rust essentially never wastes cycles on bounds checking thanks to the design of its iterators."
Can you explain this or point me to the relevant documentation or code please?
- kibwen 11y agoThe documentation on iterators describes the advantages of using iteration rather than direct indexing in a loop: http://doc.rust-lang.org/nightly/book/iterators.html http://doc.rust-lang.org/nightly/book/iterators.html The gist is that an iterator has enough information about the thing that it's iterating over that we, as library authors, can avoid unnecessary bounds checking and just perform unchecked indexing while retaining all the safety. LLVM is also surprisingly good at automatically vectorizing our iterators.
- captaincrowbar 11y agoThanks!