]> git.lizzy.rs Git - rust.git/blob - src/tools/clippy/src/docs/option_env_unwrap.txt
Auto merge of #98559 - jackh726:remove-reempty, r=oli-obk
[rust.git] / src / tools / clippy / src / docs / option_env_unwrap.txt
1 ### What it does
2 Checks for usage of `option_env!(...).unwrap()` and
3 suggests usage of the `env!` macro.
4
5 ### Why is this bad?
6 Unwrapping the result of `option_env!` will panic
7 at run-time if the environment variable doesn't exist, whereas `env!`
8 catches it at compile-time.
9
10 ### Example
11 ```
12 let _ = option_env!("HOME").unwrap();
13 ```
14
15 Is better expressed as:
16
17 ```
18 let _ = env!("HOME");
19 ```