mirror of
https://github.com/rust-lang/rust-clippy
synced 2024-11-22 04:33:15 +00:00
398be8c842
Simplify negative `Option::{is_some_and,is_none_or}` Closes #13436. Improved based on the existing lint `nonminimal_bool`, since there is already handling of similar methods `Option::{is_some,is_none}` and `Result::{is_ok,is_err}`, and there is a lot of reusable code. When `is_some_and` or `is_none_or` have a negation, we invert it into another method by removing the Not sign and inverting the expression in the closure. For the case where the closure block has statements, currently no simplification is implemented. (Should we do it?) ```rust // Currently will not simplify this _ = !opt.is_some_and(|x| { let complex_block = 100; x == complex_block }); ``` changelog: [`nonminimal_bool`]: Simplify negative `Option::{is_some_and,is_none_or}` |
||
---|---|---|
.. | ||
src | ||
Cargo.toml |