blob: 92b40a5df64889f7c89f284b954e2b160ea23ff3 (
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
28
29
30
31
32
33
34
35
36
|
### What it does
Checks for unnecessary `match` or match-like `if let` returns for `Option` and `Result`
when function signatures are the same.
### Why is this bad?
This `match` block does nothing and might not be what the coder intended.
### Example
```
fn foo() -> Result<(), i32> {
match result {
Ok(val) => Ok(val),
Err(err) => Err(err),
}
}
fn bar() -> Option<i32> {
if let Some(val) = option {
Some(val)
} else {
None
}
}
```
Could be replaced as
```
fn foo() -> Result<(), i32> {
result
}
fn bar() -> Option<i32> {
option
}
```
|