Hacker News new | ask | show | jobs
by rwaksmunski 144 days ago
Every Rust SIMD article should mention the .chunks_exact() auto vectorization trick by law.
1 comments

Didn't know about this. Thanks!

Not related, but I often want to see the next or previous element when I'm iterating. When that happens, I always have to switch to an index-based loop. Is there a function that returns Iter<Item=(T, Option<T>)> where the second element is a lookahead?

You probably just want to use `.peekable()`: https://doc.rust-lang.org/stable/std/iter/trait.Iterator.htm...
Note that `peekable` will most likely break autovectorization
I use the slice::windows for that.