Closed
Description
What it does
See title and example.
This lint should only fire if:
- the
Err
closure does nothing else except returnNone
, and... - the
Ok
parameter isSome
There is already a lint result_map_or_into_option
but that only covers r.map_or(None, Some)
, so this can either be a new lint or result_map_or_into_option
can be extended to also check for this.
Lint Name
result_map_or_else_into_option
Category
style
Advantage
The suggested code makes it more obvious what the code is doing.
Drawbacks
None.
Example
assert_eq!(Some(1), r.map_or_else(|_| None, Some));
Could be written as:
assert_eq!(Some(1), r.ok());