-
Notifications
You must be signed in to change notification settings - Fork 20
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 bool::is_false
#534
Comments
If that's a good motivating example, shouldn't there be Though I think that really wants std::fs::exists("some_path") is Ok(false) à la rust-lang/rfcs#3573, rather than (Which can be spelled with |
If this is already in a conditional, you can use if let Ok(false) = std::fs::exists("some_path") {
// ...
} I think |
that requires the |
The motivation to ACP feels like there's an XY problem here. If you need to check if a file directory is accessible and the file does not exist, chances are you'll later put a new file or directory in that place, which you should just use If it is more complicated than that I don't think |
We discussed this one in today's @rust-lang/libs-api meeting. We had a strong consensus that the right way to write this was |
Proposal
Problem statement
There should be a straightforward and readable way of checking of a boolean value is false. In some situations, using
!
(not) is unergonomic or less readable than alternatives.Motivating examples or use cases
Checking if a file does not exist.
Solution sketch
Alternatives
Don't add this. You can use a closure or
Not::not
to achieve the same thing, but it is slightly less readable.Links and related work
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):
Second, if there's a concrete solution:
The text was updated successfully, but these errors were encountered: