You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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)
The text was updated successfully, but these errors were encountered:
What it does
The methods
Option::is_some_and
andResult::is_{ok,err}_and
are designed to replace the common patternsmap_or(false, ...)
andmap_err_or(false, ...)
. Potentially could also replacemap_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
Could be written as:
The text was updated successfully, but these errors were encountered: