Macro assert_cmp::assert_fn[][src]

macro_rules! assert_fn {
    ($function:ident($left:expr, $right:expr)) => { ... };
}

Assert that a binary function call of 2 expressions returns true.

Syntax:

assert_fn!($function($left, $right))
  • $function is an identifier of a binary function.
  • $left and $right are expressions.

Example: An assertion that passes

fn func<A, B>(_: A, _: B) -> bool {
  true
}
assert_fn!(func(123, 456));

Example: An assertion that fails

fn func<A, B>(_: A, _: B) -> bool {
  false
}
assert_fn!(func(123, 456)); // panic: func(123, 456) ⇒ func(123, 456) ⇒ false