summaryrefslogtreecommitdiffstats
path: root/src/tools/clippy/src/docs/option_env_unwrap.txt
blob: c952cba8e26151217cec474aef12d9c0f26e0d56 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
### What it does
Checks for usage of `option_env!(...).unwrap()` and
suggests usage of the `env!` macro.

### Why is this bad?
Unwrapping the result of `option_env!` will panic
at run-time if the environment variable doesn't exist, whereas `env!`
catches it at compile-time.

### Example
```
let _ = option_env!("HOME").unwrap();
```

Is better expressed as:

```
let _ = env!("HOME");
```