2020-02-09 18:58:08 +00:00
|
|
|
// aux-build:macro_rules.rs
|
2020-02-09 00:44:35 +00:00
|
|
|
#![warn(clippy::option_env_unwrap)]
|
|
|
|
|
2020-02-09 18:58:08 +00:00
|
|
|
#[macro_use]
|
|
|
|
extern crate macro_rules;
|
|
|
|
|
2020-02-09 00:44:35 +00:00
|
|
|
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() {
|
2020-02-09 22:12:40 +00:00
|
|
|
let _ = option_env!("PATH").unwrap();
|
|
|
|
let _ = option_env!("PATH").expect("environment variable PATH isn't set");
|
|
|
|
let _ = option_env_unwrap!("PATH");
|
|
|
|
let _ = option_env_unwrap!("PATH", "environment variable PATH isn't set");
|
|
|
|
let _ = option_env_unwrap_external!("PATH");
|
|
|
|
let _ = option_env_unwrap_external!("PATH", "environment variable PATH isn't set");
|
2020-02-09 00:44:35 +00:00
|
|
|
}
|