summaryrefslogtreecommitdiffstats
path: root/src/tools/clippy/src/docs/or_then_unwrap.txt
blob: 64ac53749e8ad92353deb102446b4334aecde272 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
### What it does
Checks for `.or(…).unwrap()` calls to Options and Results.

### Why is this bad?
You should use `.unwrap_or(…)` instead for clarity.

### Example
```
// Result
let value = result.or::<Error>(Ok(fallback)).unwrap();

// Option
let value = option.or(Some(fallback)).unwrap();
```
Use instead:
```
// Result
let value = result.unwrap_or(fallback);

// Option
let value = option.unwrap_or(fallback);
```