Partition iterator - best practice and design guidance

A possibility you could consider is this (ResultShunt-inspired) sketch I made a while ago: https://play.rust-lang.org/?version=nightly&edition=2018&gist=819dd12076a2a7add7cfd8733b8b03bd

That uses extend, but could be tweaked to just take a different error handler closure. Then it'd still be lazy, one-pass, and non-allocating, with the "normal" iterator route dealing with the Oks and the slightly-out-of-band closure dealing with the Errs as they show up.

2 Likes