Skip to main content

as_expr_or_err

Macro as_expr_or_err 

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

Macro to unwrap an Option to Expr or return an error. Returns the expression on success, or returns Err(anyhow::Error) on failure.

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

§Usage

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

§Arguments

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