assert_ok

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 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> = Ok(1);
assert_ok!(a);

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

§Module macros