tuple_windows clones the iterator elements so that they can be part of successive windows, this makes it most suited for iterators of references and other values that are cheap to copy.

( All the excellent forumites here make it so hard to be helpful; by the time I’ve worked through a problem I’m trying to be helpful on, I’m usually already ninja’d twice by other even-more-helpful people, who provide even-better-solutions. Frustrating! )

Also seems that we already have the iterator adapter in itertools::tuple_windows(), which clones all the values.

Sorry for derailing a bit, but that reminds me, is Rust planning on adding const-generics any time soon? [T; N] is currently being implemented in tons of projects with macro hacks up to [T; 32] or something like that, which is nowhere near ideal.

Not to derail further, but same goes for generic type constructors, which will make streaming iterators possible with clean code (which is what you need in the other thread to borrow from the iterator when returning a result).