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