Add flat_map_ok iterator adaptor#1087
Conversation
Implements flat_map_ok, which applies a function to Ok(T) values and flattens the resulting iterator, passing Err values through unchanged. Equivalent to .map_ok(f).flatten_ok() but avoids the intermediate iterator type. Supports DoubleEndedIterator, FusedIterator, Clone, Debug, fold/rfold optimizations. Closes rust-itertools#528
|
Test results: Full test suite also passes (202 tests). |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #1087 +/- ##
==========================================
- Coverage 94.38% 93.19% -1.20%
==========================================
Files 48 52 +4
Lines 6665 6571 -94
==========================================
- Hits 6291 6124 -167
- Misses 374 447 +73 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
Hi there, thanks for this. I'm reluctant to include even more convenience functions. Can you elaborate why this new iterator is strictly better than |
|
That's a fair question — |
Adds a
flat_map_okadaptor that applies a function toOkvalues and flattens the result, passingErrvalues through unchanged. Basically a combined.map_ok(f).flatten_ok()in a single step.The implementation follows the same pattern as the existing
flatten_okadaptor, with support for:DoubleEndedIterator(when the inner iterator supports it)FusedIteratorClone/Debugfold/rfoldoptimizationsExample usage:
Closes #528