Skip to content

Add Option::is_none_or#100602

Closed
OliveIsAWord wants to merge 1 commit into
rust-lang:masterfrom
OliveIsAWord:master
Closed

Add Option::is_none_or#100602
OliveIsAWord wants to merge 1 commit into
rust-lang:masterfrom
OliveIsAWord:master

Conversation

@OliveIsAWord

@OliveIsAWord OliveIsAWord commented Aug 15, 2022

Copy link
Copy Markdown

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

rustbot commented Aug 15, 2022

Copy link
Copy Markdown
Collaborator

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
Copy Markdown
Contributor

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

thomcc commented Aug 15, 2022

Copy link
Copy Markdown
Member

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

Comment thread library/core/src/option.rs Outdated

Copy link
Copy Markdown
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
Copy Markdown
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

thomcc commented Aug 15, 2022

Copy link
Copy Markdown
Member

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
Copy Markdown
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
Copy Markdown
Author

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

Comment thread library/core/src/option.rs Outdated
@camsteffen

Copy link
Copy Markdown
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
Copy Markdown
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

m-ou-se commented May 19, 2023

Copy link
Copy Markdown
Member

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