mirror of
https://github.com/rust-lang/rust-clippy
synced 2024-12-22 19:13:29 +00:00
38d4ac7cea
Discussion previously happened in https://github.com/rust-lang/rust/pull/43498
27 lines
1.4 KiB
Text
27 lines
1.4 KiB
Text
error: called `map(f).unwrap_or_else(g)` on a Result value. This can be done more directly by calling `ok().map_or_else(g, f)` instead
|
|
--> $DIR/result_map_unwrap_or_else.rs:15:13
|
|
|
|
|
LL | let _ = res.map(|x| x + 1).unwrap_or_else(|e| 0); // should lint even though this call is on a separate line
|
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
|
|
|
|
= note: `-D clippy::result-map-unwrap-or-else` implied by `-D warnings`
|
|
= note: replace `map(|x| x + 1).unwrap_or_else(|e| 0)` with `ok().map_or_else(|e| 0, |x| x + 1)`
|
|
|
|
error: called `map(f).unwrap_or_else(g)` on a Result value. This can be done more directly by calling `ok().map_or_else(g, f)` instead
|
|
--> $DIR/result_map_unwrap_or_else.rs:17:13
|
|
|
|
|
LL | let _ = res.map(|x| x + 1).unwrap_or_else(|e| 0);
|
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
|
|
|
|
= note: replace `map(|x| x + 1).unwrap_or_else(|e| 0)` with `ok().map_or_else(|e| 0, |x| x + 1)`
|
|
|
|
error: called `map(f).unwrap_or_else(g)` on a Result value. This can be done more directly by calling `ok().map_or_else(g, f)` instead
|
|
--> $DIR/result_map_unwrap_or_else.rs:18:13
|
|
|
|
|
LL | let _ = res.map(|x| x + 1).unwrap_or_else(|e| 0);
|
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
|
|
|
|
= note: replace `map(|x| x + 1).unwrap_or_else(|e| 0)` with `ok().map_or_else(|e| 0, |x| x + 1)`
|
|
|
|
error: aborting due to 3 previous errors
|
|
|