blob: fc4b528f0923e843a31eaa75187860b9dd14c380 (
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
27
|
### What it does
Checks for usage of `option.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: Option<String> = do_stuff();
x.map(log_err_msg);
x.map(|msg| log_err_msg(format_msg(msg)));
```
The correct use would be:
```
let x: Option<String> = do_stuff();
if let Some(msg) = x {
log_err_msg(msg);
}
if let Some(msg) = x {
log_err_msg(format_msg(msg));
}
```
|