-
Couldn't load subscription status.
- Fork 1.8k
Open
Labels
A-lintArea: New lintsArea: New lints
Description
What it does
The methods Option::is_some_and and Result::is_{ok,err}_and are designed to replace the common patterns map_or(false, ...) and map_err_or(false, ...). Potentially could also replace map_or(true, ...) with !is_some_and(!...). Probably should be a pedantic lint.
#9125 is similar but for map(...).unwrap_or(false).
Advantage
Expresses the intent better and is slightly more concise.
Drawbacks
No response
Example
Some(42).map_or(false, |value| value > 0)Could be written as:
Some(42).is_some_and(|value| value > 0)kornelski
Metadata
Metadata
Assignees
Labels
A-lintArea: New lintsArea: New lints