assert_some_ne

Macro assert_some_ne 

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

Assert two expressions are Some and their values are not equal.

Pseudocode:
(a ⇒ Some(a1) ⇒ a1) ≠ (b ⇒ Some(b1) ⇒ b1)

  • If true, return (a1, b1).

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

§Examples

use assertables::*;

let a: Option<i8> = Option::Some(1);
let b: Option<i8> = Option::Some(2);
assert_some_ne!(a, b);

// This will panic
let a: Option<i8> = Option::Some(1);
let b: Option<i8> = Option::Some(1);
assert_some_ne!(a, b);
// assertion failed: `assert_some_ne!(a, b)`
// https://docs.rs/assertables/…/assertables/macro.assert_some_ne.html
//  a label: `a`,
//  a debug: `Some(1)`,
//  b label: `b`,
//  b debug: `Some(1)`,
//  a inner: `1`,
//  b inner: `1`

§Module macros