macro_rules! die {
() => { ... };
($x:expr) => { ... };
($x:expr; $y:expr) => { ... };
($x:expr; $($y:expr),+) => { ... };
($($y:expr),+; $x:expr) => { ... };
($($arg:tt)*) => { ... };
}Expand description
Prints a message to stderr and terminates the current process with the specified exit code
or 1 if no exit code is specified, by calling eprintln!() on all arguments followed by
process::exit(exit_code)
ยงExamples
Basic usage:
die!("argument to -e must be numeric"); // prints message to stderr then exits with code 1With custom error code:
die!(2; "argument to -e must be numeric"); // prints message to stderr then exits with code 2error code can go at the beginning or end, just separate with colon:
die!("argument to -e must be numeric"; 3); // prints message to stderr then exits with code 3supports all the formatting eprintln! does:
die!("argument {} must be {}", "-e", 1; 4); // prints `argument -e must be 1` to stderr then exits with code 4supports all the formatting eprintln! does without exit code too:
die!("argument {} must be {}", "-e", 1); // prints `argument -e must be 1` to stderr then exits with code 1just exit with a code alone:
die!(2); // prints nothing, only exits with code 3just exit:
die!(); // prints nothing, only exits with code 1