Macro assert_err

Source
macro_rules! assert_err {
    ($a:expr $(,)?) => { ... };
    ($a:expr, $($message:tt)+) => { ... };
}
Expand description

Assert expression is Err.

Pseudocode:
a is Err(a1)

  • If true, return a1.

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

§Examples

use assertables::*;

let a: Result<i8, i8> = Err(1);
assert_err!(a);

// This will panic
let a: Result<i8, i8> = Ok(1);
assert_err!(a);
// assertion failed: `assert_err!(a)`
// https://docs.rs/assertables/…/assertables/macro.assert_err.html
//  a label: `a`,
//  a debug: `Ok(1)`

§Module macros