Am I the only one who uses non-fused iterators?

Yes, one use I remember of the top of my head was where I needed something like Windows per-row in a 3d array-esque data structure[1], consumed in a nested loop. Resumability was a natural for the implementation and the consumption. Basically if the current row is consumed, chop up the uniterated slice into the next row and remainder and return None; the subsequent next call will resume iteration in the new row.

I've never considered it odd since I've understood that non-fused iterators have been a part of the design from the start. That's why fusing is it's own method / trait. This came up recently in some other thread and I made a token effort to find the source of not assuming iterators to be fused, but gave up with a shrug after finding references to unfused iterators in discussions from 2013 or so. I.e. I concluded it's been like this in Rust "forever"ish.


  1. triangular actually ↩︎

4 Likes