Re:Writing a JPEG Decoder in Rust – Part 2: Implementation I
by steveklabnik on Friday August 19, 2016 @02:41PM
(#12322379)
I'm not 100% sure, but https://crates.io/crates/itertools might have what you're looking for.
Re:Writing a JPEG Decoder in Rust – Part 2: Implementation I
by elktea on Friday August 19, 2016 @08:30PM
(#12324443)
I think http://bluss.github.io/rust-itertools/doc/itertools/struct.Z... would fit their use case?
Re:Writing a JPEG Decoder in Rust – Part 2: Implementation I
by dbaupp on Friday August 19, 2016 @02:45PM
(#12322420)
The `.windows(usize)` function almost does this, but it uses a runtime width and so has to yield slices rather than tuples.
I find myself wanting to walk an iterator pairwise regularly for stuff like this and I'm using:
Is there a better way to write this? What I'd really like is the equivalent to Clojure's partition[1]. I know that the stdlib has windows `(partition n (dec n) seq)` and chunks `(partition n n seq)` implemented on slices but I usually want this on iterators for the lookahead-like behavior shown here.[1] https://clojuredocs.org/clojure.core/partition