Skip to main content

as_expr_or_opt_err

Macro as_expr_or_opt_err 

Source
macro_rules! as_expr_or_opt_err {
    ($opt:expr, $error_msg:expr) => { ... };
}
Expand description

Macro to unwrap an Option to Expr for functions returning Option. Returns the expression on success, or returns Some(Err(anyhow::Error)) on failure.

This macro is designed for use in functions that return Option<Result<T, anyhow::Error>>.

§Usage

let expr = as_expr_or_opt_err!(result_value, "Argument not expression");

§Arguments

  • $opt: The EvaluateResultValue to unwrap
  • $error_msg: Error message string literal