What it does
This lint should suggest calling Option::ok_or or Option::ok_or_else when this functionality is reimplemented using the Option::map_or or Option::map_or_else functions, respectively.
Categories (optional)
Makes it clearer that this is converting from an Option to a Result, and produces shorter code.
Drawbacks
None.
Example
optional.map_or(
Err(0),
|x| Ok(x),
)
Could be written as:
What it does
This lint should suggest calling
Option::ok_ororOption::ok_or_elsewhen this functionality is reimplemented using theOption::map_ororOption::map_or_elsefunctions, respectively.Categories (optional)
Makes it clearer that this is converting from an
Optionto aResult, and produces shorter code.Drawbacks
None.
Example
Could be written as: