rust/tests/ui/option_env_unwrap.rs

18 lines
479 B
Rust
Raw Normal View History

2020-02-09 00:44:35 +00:00
#![warn(clippy::option_env_unwrap)]
macro_rules! option_env_unwrap {
($env: expr) => {
option_env!($env).unwrap()
};
($env: expr, $message: expr) => {
option_env!($env).expect($message)
};
2020-02-09 00:44:35 +00:00
}
fn main() {
let _ = option_env!("HOME").unwrap();
let _ = option_env!("HOME").expect("environment variable HOME isn't set");
2020-02-09 00:44:35 +00:00
let _ = option_env_unwrap!("HOME");
let _ = option_env_unwrap!("HOME", "environment variable HOME isn't set");
2020-02-09 00:44:35 +00:00
}