Suggests using opt.is_none_or(...) instead of !opt.is_some_and(...), also suggests to invert the boolean expression inside the closure to keep the two equivalent.
I can imagine some algorithm that will try to invert the expression in the 'nicest' way, converting (just examples)
a < b to a >= b
a == b to a != b
result.is_ok() to result.is_err()
!(expr) to expr
Finally, if the above do not work for a specific expression, just put a ! in front of the expression, and parentheses around it if necessary.
If a function pointer is passed in, convert it to a closure and put ! in front of it (|args| !function(args)).
Advantage
Convert harder to read !(option is some && some expression) to option is none || !(some expression).
Drawbacks
This can introduce unnecessary closures (see last line of "What it does").
What it does
Suggests using
opt.is_none_or(...)
instead of!opt.is_some_and(...)
, also suggests to invert the boolean expression inside the closure to keep the two equivalent.I can imagine some algorithm that will try to invert the expression in the 'nicest' way, converting (just examples)
a < b
toa >= b
a == b
toa != b
result.is_ok()
toresult.is_err()
!(expr)
toexpr
!
in front of the expression, and parentheses around it if necessary.If a function pointer is passed in, convert it to a closure and put
!
in front of it (|args| !function(args)
).Advantage
!(option is some && some expression)
tooption is none || !(some expression)
.Drawbacks
Example
Could be written as: