Anonymous Impls

I often find myself writing a function that internally defines a struct just so I can implement a trait on it and return that type as an impl Trait . To see what I mean, let's look at a concrete example. We'll write a function that takes an iterator that yields, for example, 1, 2, 3, 4 and returns a new iterator that yields (1, 2), (3, 4). /// Assumes the input iterator yields an even number of…