rust-itertools / itertools

Extra iterator adaptors, iterator methods, free functions, and macros.
https://docs.rs/itertools/
Apache License 2.0
2.69k stars 303 forks source link

flat_map_ok #528

Open oberien opened 3 years ago

oberien commented 3 years ago

Similar to #522, which defines flatten_ok, there could also be a flat_map_ok which operates on an IntoIter<Item = Result<T, E>>, applies a function to T if the value is Ok and flattens the result of that function. It should be equivalent to iterator.map_ok(function).flatten_ok().

SkiFire13 commented 3 years ago

And what about something that acts like iterator.map(function).flatten_ok()?

scottmcm commented 3 years ago

Hmm, is it really best to have an _ok version of just about everything?

Are these scenarios where it might be better to use something like https://docs.rs/fallible-iterator/0.2.0/fallible_iterator/trait.FallibleIterator.html that's specifically for the Result case?

Atry commented 1 year ago

I feel the two projects should be merged. rust-itertools and fallible-iterator just include similar implementations but different interfaces.