assertables

Macro assert_ok

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

Assert expression is Ok(_).

Pseudocode:
a is Ok(_)

  • If true, return ().

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

§Examples

use assertables::*;

let a: Result<(), i8> = Ok(());
assert_ok!(a);

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

§Module macros