I wrote a macro but now I am trying to extend it so I can pass it a function. I read the Rust Reference and I don't really understand metavariables. I feel like everything I want is going to be an expression, but how can I pass error
to an expression without breaking everything?
macro_rules! unwrap_or_return {
( $a:expr, $b:expr ) => {
match $a {
Ok(x) => x,
Err(_) => return Err($b),
}
};
// new part
( $a:expr, $fun:FUNCTION ) => {
match $a {
Ok(x) => x,
Err(error) => return Err($fun(error)),
}
};
}