Skip to content

Tracking Issue for Iterator::try_find #63178

Open

Description

@MOZGIII

Adds try_find to Iterator.

PR: #63177

fn try_find<F, E, R>(&mut self, f: F) -> Result<Option<Self::Item>, E>
where
    F: FnMut(&Self::Item) -> R,
    R: Try<Ok = bool, Error = E>;

Open questions:

Activity

  1. added
    B-unstableBlocker: Implemented in the nightly compiler and unstable.
    C-tracking-issueCategory: An issue tracking the progress of sth. like the implementation of an RFC
    T-libs-api[DEPRECATED; DO NOT USE]
    on Aug 1, 2019
  2. changed the title [-]Tracking Issue for Iterator::find_result[/-] [+]Tracking Issue for Iterator::try_find[/+] on Aug 6, 2019
  3. added
    requires-nightlyThis issue requires a nightly compiler in some way. When possible, use a F-* label instead.
    on Aug 8, 2019
  4. added a commit that references this issue on Jan 2, 2020
  5. MOZGIII commented on Jan 4, 2020

    @MOZGIII
    ContributorAuthor

    I'll start test-running it in the field. The next step for this feature would be to allow coupling the resulting Try type with the closure return type. Apparently, GAT would allow a way to implement this.

  6. added
    Libs-SmallLibs issues that are considered "small" or self-contained
    I-libs-radarLibs issues that are tracked on the team's radar.
    on Jul 29, 2020
  7. mikeyhew commented on Aug 20, 2020

    @mikeyhew
    Contributor

    Is there an easy workaround to use until this is stabilized?

  8. MOZGIII commented on Aug 20, 2020

    @MOZGIII
    ContributorAuthor

    You can use this crate for now: https://github.com/MOZGIII/iter-try-rs

  9. mikeyhew commented on Aug 25, 2020

    @mikeyhew
    Contributor

    @MOZGIII thanks. I realized I had a .map call after the .find that I was replacing, so I switched to .filter_map(...).transpose()?

  10. scottmcm commented on May 7, 2021

    @scottmcm
    Member

    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 Poll<Result<_, _>>, anything in a family of Try types that can accept Option<_> as the Output type...)

  11. Jesse-Bakker commented on Nov 21, 2022

    @Jesse-Bakker
    Contributor

    With the resolution of #85115, are there any issues blocking stabilization, besides stabilization of ops::Residual?

  12. MOZGIII commented on Nov 21, 2022

    @MOZGIII
    ContributorAuthor

    Thanks for the update!

    I'd say we can go ahead with the stabilization.

  13. Ciel-MC commented on Aug 24, 2023

    @Ciel-MC
    Contributor

    Hello, why this hasn't been stabilized yet?

  14. MOZGIII commented on Aug 24, 2023

    @MOZGIII
    ContributorAuthor

    Indeed, I'll send a PR to it forward when I have time, hopefully this week

  15. scottmcm commented on Aug 28, 2023

    @scottmcm
    Member

    Note that this, like array::try_from_fn and Iterator::try_collect and similar, depends on the Residual trait mechanism for mapping from Foo<A> to Foo<[A; N]>, which is not used in any stable functions right now, so stabilization here is a bigger question than just the specific function in question.

    See #94119 (comment) where array::from_fn was accepted but array::try_from_fn wasn't accepted due to this.

  16. MOZGIII commented on Sep 2, 2023

    @MOZGIII
    ContributorAuthor

    Thanks for the feedback, I wasn't aware of this Residual blocker...
    Also, I have realized I didn't exactly follow the procedure for the stabilization, so I'll have to read up on that before creating the PR itself (and trigger the final comment period and etc).

    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 Residual trait (UPD: which is try_trait_v2 apparently), together with the other things that are blocked by it.
    Should we create a new tracking issue, or bring it up in the Residual tracking issue?

    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 try/? itself). So, maybe this is not so big of a concern?

  17. MOZGIII commented on Mar 4, 2025

    @MOZGIII
    ContributorAuthor

    Hey, it seems like this keeps slipping though the cracks for me. Anyone wants to pick this up and move to completion?

  18. added
    T-libsRelevant to the library team, which will review and decide on the PR/issue.
    and removed
    T-libs-api[DEPRECATED; DO NOT USE]
    on Aug 12, 2026
  19. added
    E-easyCall for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue.
    and removed
    Libs-SmallLibs issues that are considered "small" or self-contained
    on Oct 7, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-iteratorsArea: IteratorsB-unstableBlocker: Implemented in the nightly compiler and unstable.C-tracking-issueCategory: An issue tracking the progress of sth. like the implementation of an RFCE-easyCall for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue.I-libs-radarLibs issues that are tracked on the team's radar.T-libsRelevant to the library team, which will review and decide on the PR/issue.requires-nightlyThis issue requires a nightly compiler in some way. When possible, use a F-* label instead.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions