assertables

Macro assert_fn_eq_expr

source
macro_rules! assert_fn_eq_expr {
    ($a_function:path, $a_param:expr, $b_expr:expr $(,)?) => { ... };
    ($a_function:path, $a_param:expr, $b_expr:expr, $($message:tt)+) => { ... };
    ($a_function:path, $b_expr:expr $(,)?) => { ... };
    ($a_function:path, $b_expr:expr, $($message:tt)+) => { ... };
}
Expand description

Assert a function output is equal to an expression.

Pseudocode:
function(a) = b

  • If true, return ().

  • Otherwise, call panic! with a message and the values of the expressions with their debug representations.

§Examples

let a: i8 = -1;
let b: i8 = 1;
assert_fn_eq_expr!(i8::abs, a, b);

let a: i8 = -1;
let b: i8 = 2;
assert_fn_eq_expr!(i8::abs, a, b);
// assertion failed: `assert_fn_eq_expr!(a_function, a_param, b_expr)`
// https://docs.rs/assertables/8.9.0/assertables/macro.assert_fn_eq_expr.html
//  a_function label: `i8::abs`,
//     a_param label: `a`,
//     a_param debug: `-1`,
//      b_expr label: `b`,
//      b_expr debug: `2`,
//                 a: `1`,
//                 b: `2`

§Module macros