2020-02-09 12:58:08 -06:00
|
|
|
// aux-build:macro_rules.rs
|
2020-02-08 18:44:35 -06:00
|
|
|
#![warn(clippy::option_env_unwrap)]
|
|
|
|
|
2020-02-09 12:58:08 -06:00
|
|
|
#[macro_use]
|
|
|
|
extern crate macro_rules;
|
|
|
|
|
2020-02-08 18:44:35 -06:00
|
|
|
macro_rules! option_env_unwrap {
|
|
|
|
($env: expr) => {
|
|
|
|
option_env!($env).unwrap()
|
|
|
|
};
|
2020-02-09 10:54:23 -06:00
|
|
|
($env: expr, $message: expr) => {
|
|
|
|
option_env!($env).expect($message)
|
|
|
|
};
|
2020-02-08 18:44:35 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
fn main() {
|
|
|
|
let _ = option_env!("HOME").unwrap();
|
2020-02-09 10:54:23 -06:00
|
|
|
let _ = option_env!("HOME").expect("environment variable HOME isn't set");
|
2020-02-08 18:44:35 -06:00
|
|
|
let _ = option_env_unwrap!("HOME");
|
2020-02-09 10:54:23 -06:00
|
|
|
let _ = option_env_unwrap!("HOME", "environment variable HOME isn't set");
|
2020-02-09 12:58:08 -06:00
|
|
|
let _ = option_env_unwrap_external!("HOME");
|
|
|
|
let _ = option_env_unwrap_external!("HOME", "environment variable HOME isn't set");
|
2020-02-08 18:44:35 -06:00
|
|
|
}
|