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 is_xxx_or for Result and Option #343

Closed
Embers-of-the-Fire opened this issue Feb 25, 2024 · 1 comment
Closed

Add is_xxx_or for Result and Option #343

Embers-of-the-Fire opened this issue Feb 25, 2024 · 1 comment
Labels
api-change-proposal A proposal to add or alter unstable APIs in the standard libraries T-libs-api

Comments

@Embers-of-the-Fire
Copy link

Proposal

Problem statement

Currently missing antonymous predicate for is_some_and(Option) (or is_ok/err_and(Result)).

Motivation

Just as is_some has is_none as an antonym, is_xxx_and should also have an antonym. This doesn't add code to the standard library (in fact the majority of the code is in the documented code examples), but it makes the code logic clearer. (Maybe it's just that the antonym wasn't considered when this feature was originally designed.)

Solution sketch

Something like:

pub fn is_none_or(self, f: impl FnOnce(T) -> bool) -> bool

Alternatives

  • No changes
  • [Internal impl] !is_some_and?

Links and related work

rust-lang/rust/pull/118090 - [Core] Add is_xxx_or for Result and Option

What happens now?

This issue contains an API change proposal (or ACP) and is part of the libs-api team feature lifecycle. Once this issue is filed, the libs-api team will review open proposals as capability becomes available. Current response times do not have a clear estimate, but may be up to several months.

Possible responses

The libs team may respond in various different ways. First, the team will consider the problem (this doesn't require any concrete solution or alternatives to have been proposed):

  • We think this problem seems worth solving, and the standard library might be the right place to solve it.
  • We think that this probably doesn't belong in the standard library.

Second, if there's a concrete solution:

  • We think this specific solution looks roughly right, approved, you or someone else should implement this. (Further review will still happen on the subsequent implementation PR.)
  • We're not sure this is the right solution, and the alternatives or other materials don't give us enough information to be sure about that. Here are some questions we have that aren't answered, or rough ideas about alternatives we'd want to see discussed.
@Embers-of-the-Fire Embers-of-the-Fire added api-change-proposal A proposal to add or alter unstable APIs in the standard libraries T-libs-api labels Feb 25, 2024
@the8472
Copy link
Member

the8472 commented Feb 25, 2024

see #212

@Embers-of-the-Fire Embers-of-the-Fire closed this as not planned Won't fix, can't repro, duplicate, stale Feb 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api-change-proposal A proposal to add or alter unstable APIs in the standard libraries T-libs-api
Projects
None yet
Development

No branches or pull requests

2 participants