-
Notifications
You must be signed in to change notification settings - Fork 12.9k
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
Tracking Issue for Iterator::try_find #63178
Comments
Add Iterator::try_find I found a need for this fn, and created this PR. Tracking issue: #63178 I did a fair amount of thinking about the function name, and settled on the current one. I don't see other anything else that's non-trivial here, but I'm open for debate. I just want this functionality to be there. It couples with the `collect` trick for collecting `Result<Vec<T>, E>` from `Iterator<Item = Result<T, E>>`. UPD: I've already looked at `fallible_iterator` crate, but I don't think it supports my use case. The main problem is that I can't construct a failable iterator. I have a regular iterator, and I just need to apply a predicate that can fail via `find` method. UPD: `fallible_iterator` would work, but it's not elegant cause I'd have to make a failable iterator by mapping iterator with `Result::Ok` first.
I'll start test-running it in the field. The next step for this feature would be to allow coupling the resulting |
Is there an easy workaround to use until this is stabilized? |
You can use this crate for now: https://github.com/MOZGIII/iter-try-rs |
@MOZGIII thanks. I realized I had a |
Wanted to drop a mention of https://rust-lang.github.io/rfcs/3058-try-trait-v2.html#possibilities-for-try_find in here -- figuring out exactly how this should work is probably a blocker for stabilization here (just Result, just things compatible with Result, like |
With the resolution of #85115, are there any issues blocking stabilization, besides stabilization of |
Thanks for the update! I'd say we can go ahead with the stabilization. |
Hello, why this hasn't been stabilized yet? |
Indeed, I'll send a PR to it forward when I have time, hopefully this week |
Note that this, like See #94119 (comment) where |
Thanks for the feedback, I wasn't aware of this Also, we have GAT now, so we might want to revisit the design. It might make sense to organize the stabilization of this feature in a larger chunk of work around the stabilization of the At the same time, we did have situations in the past where certain traits were unstable while other stable things depended on them (for instance, the |
Adds
try_find
toIterator
.PR: #63177
Open questions:
Result
, vs potentially supportingOption
and otherTry
types Decide on generic-ness of functions likeIterator::try_find
andarray::try_map
#85115The text was updated successfully, but these errors were encountered: