blob: 3455c5c1f9b8a0c4eea5f13fdabee13fde2348c7 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
|
### What it does
Checks for usage of `result.map(f)` where f is a function
or closure that returns the unit type `()`.
### Why is this bad?
Readability, this can be written more clearly with
an if let statement
### Example
```
let x: Result<String, String> = do_stuff();
x.map(log_err_msg);
x.map(|msg| log_err_msg(format_msg(msg)));
```
The correct use would be:
```
let x: Result<String, String> = do_stuff();
if let Ok(msg) = x {
log_err_msg(msg);
};
if let Ok(msg) = x {
log_err_msg(format_msg(msg));
};
```
|