News for hackers. Stuff that matters.
Re:Zig's Curious Multi-Sequence for Loops by steveklabnik on Monday February 27, 2023 @05:03PM (#34962557)
I tossed together a simple function using enumerate https://godbolt.org/z/PKsEdKvKK

You get the same exact asm as the manual loop.

Of course, the idiom recognition seems to kick in, in both cases, as there's no actual loop here. I tossed in a +sum, which makes that fail, so you get some loops, check it out:

https://godbolt.org/z/1ddf5ded7

They are one instruction different in length, which is kind of amusing to me. Some small differences.

Re:Zig's Curious Multi-Sequence for Loops by cgh on Monday February 27, 2023 @05:33PM (#34962943)
Thanks, that’s exactly what I was asking. I don’t write Rust so it’s informative to see this.
Re:Zig's Curious Multi-Sequence for Loops by steveklabnik on Monday February 27, 2023 @05:52PM (#34963137)
Any time.