Skip to content
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

Add Option::is_none_or #100602

Closed
wants to merge 1 commit into from
Closed

Conversation

OliveIsAWord
Copy link

@OliveIsAWord OliveIsAWord commented Aug 15, 2022

This is my first contribution to Rust, so I welcome any churn no matter how pedantic. :)

This was discussed on this tracking issue.

@rustbot rustbot added the T-libs Relevant to the library team, which will review and decide on the PR/issue. label Aug 15, 2022
@rustbot
Copy link
Collaborator

rustbot commented Aug 15, 2022

Hey! It looks like you've submitted a new PR for the library teams!

If this PR contains changes to any rust-lang/rust public library APIs then please comment with @rustbot label +T-libs-api -T-libs to tag it appropriately. If this PR contains changes to any unstable APIs please edit the PR description to add a link to the relevant API Change Proposal or create one if you haven't already. If you're unsure where your change falls no worries, just leave it as is and the reviewer will take a look and make a decision to forward on if necessary.

Examples of T-libs-api changes:

  • Stabilizing library features
  • Introducing insta-stable changes such as new implementations of existing stable traits on existing stable types
  • Introducing new or changing existing unstable library APIs (excluding permanently unstable features / features without a tracking issue)
  • Changing public documentation in ways that create new stability guarantees
  • Changing observable runtime behavior of library APIs

@rust-highfive
Copy link
Collaborator

Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @thomcc (or someone else) soon.

Please see the contribution instructions for more information.

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Aug 15, 2022
@thomcc
Copy link
Member

thomcc commented Aug 15, 2022

Hi, this is a new unstable API, so you need to file an ACP for this. See the bots message for the process. Thanks.

/// ```
#[must_use]
#[inline]
#[unstable(feature = "is_some_with", issue = "93050")]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
#[unstable(feature = "is_some_with", issue = "93050")]
#[unstable(feature = "option_is_none_or", issue = "none")]

For now. But you can wait for the ACP to be resolved.

@thomcc thomcc added S-waiting-on-ACP Status: PR has an ACP and is waiting for the ACP to complete. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Aug 15, 2022
@OliveIsAWord
Copy link
Author

r? @m-ou-se

@rust-highfive rust-highfive assigned m-ou-se and unassigned thomcc Aug 15, 2022
@thomcc thomcc added T-libs-api Relevant to the library API team, which will review and decide on the PR/issue. and removed T-libs Relevant to the library team, which will review and decide on the PR/issue. labels Aug 15, 2022
@thomcc
Copy link
Member

thomcc commented Aug 15, 2022

Ah, I didn't see the message about the tracking issue (or perhaps you edited it). I guess this possibly can skip ACP? No strong feelings from me either way.

@OliveIsAWord
Copy link
Author

I'm guessing it would be part of the is_some_with tracking issue, but I obviously defer to Mara Bos for the final say.

@OliveIsAWord
Copy link
Author

I should also mention that, based on a rudimentary Godbolt test, this new method seems to optimize nicely.

@camsteffen
Copy link
Contributor

Can we have is_err_or added with this?

I ran into a case the other day where I wanted to write:

    .filter(|r| r.is_err_or(|value| value.something()))
    .collect::<Result<_, _>();

@OliveIsAWord
Copy link
Author

Can we have is_err_or added with this?

I think this case might be sufficiently covered by r.ok().is_none_or(...), and if we did add is_err_or, should we also add is_ok_or? Suffice to say, I think that would be a bikeshedding conversation for another PR.

@m-ou-se
Copy link
Member

m-ou-se commented May 19, 2023

Thanks for your PR. I'm closing this as we decided not to add this method to Option. See rust-lang/libs-team#212.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-ACP Status: PR has an ACP and is waiting for the ACP to complete. T-libs-api Relevant to the library API team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants