inefficient_unwrap_or
Default: Enabled
What it does
Finds calls of Option::unwrap_or or Result::unwrap_or which can be optimized by lazy-evaluation, using unwrap_or_else.
Example
cairo
fn foo() -> usize {
// Some heavy computation here
0
}
let x: Option<i32> = None;
let y = x.unwrap_or(foo());Can be optimized:
cairo
let y = x.unwrap_or_else(|| foo());