macro_rules! unwrap_or_panic {
($result:expr) => { ... };
($result:expr, $context:expr) => { ... };
}Expand description
Macro to unwrap a Result or panic with the error message.
This is a cleaner replacement for .unwrap_or_else(|error| panic!("{}", error)).
§Usage
ⓘ
let value = unwrap_or_panic!(expr_to_num(&arg, state, traversal_state, fns));
// Or with additional context:
let value = unwrap_or_panic!(expr_to_num(&arg, state, traversal_state, fns), "Converting to number");§Arguments
$result: A Result type to unwrap$context(optional): Additional context string to prepend to the error message