-
Notifications
You must be signed in to change notification settings - Fork 321
Add try_map_results
method.
#283
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Add try_map_results
method.
#283
Conversation
@bluss This is ready for review, whenever you have time. |
@pthariensflame sorry for taking forever. Can we check if this is something that Rust's std wants to take? |
I suppose. I was assuming they wouldn't, since the |
@pthariensflame Either opening a PR there or checking interest with people in the libs team. Though I see your point, this seems to fit better in here. No chance some kind of In std with the |
cc @Centril :) what do you think? |
@bluss Hmm; this seems to me a shorthand for |
95342cb
to
b3f31e7
Compare
Sorry for the wait. Generally, I think we should stick with the |
@jswrenn Maybe |
@pthariensflame |
b3f31e7
to
389acab
Compare
@jswrenn How's it look now? |
I have nothing against extending our @pthariensflame I am sorry that this issue came to my mind so late. Would you also be ok with incorporating your idea once/if #464 becomes accepted? |
@philmuemue I’d be more than happy to! |
464: Unify convenience map functions r=jswrenn a=phimuemue In response to #283: I think we should employ a uniform architecture for our `map`-specializations (as they already diverged). This PR is meant to unify the implementations so we essentially only need to parametrize the mapping function: * Generalize `MapInto` to `MapSpecialCase` (which can be used as basis for all our map convenience functions) and define `MapInto` in terms of `MapSpecialCase` * Specialize `collect` (was specialized on `MapOk`, so I guess we want to keep it for now) * Define `MapOk` in terms of `MapSpecialCase` * Simple tests for specialized `size_hint`, `fold`, `collect` * As at this point probably all existing PRs involving `map_xyz` are conflicting anyway, move them to an own module (similar to `coalesce`) Co-authored-by: philipp <descpl@yahoo.de>
This method is like the existing
map_results
, but allows the provided closure to potentially fail with anErr
value of its own on each input. TheErr
values from both the original iterator and the closure will show up in the output of the adaptor.I felt the need for this method very recently in my own code; it's implementable manually in terms of
Itertools::map_results
,Iterator::map
, andResult::and_then
, but it's both cleaner and more obviously efficient if it's its own method.