Macro assertables::assertable_ne
source · [−]macro_rules! assertable_ne {
($left:expr, $right:expr $(,)?) => { ... };
($left:expr, $right:expr, $($arg:tt)+) => { ... };
}Expand description
Assert a value is not equal to another.
-
When true, return
Ok(()). -
When false, return
Errwith a message and the values of the expressions with their debug representations.
Examples
let x = assertable_ne!(1, 2);
//-> Ok(())
assert_eq!(x.unwrap(), ());
let x = assertable_ne!(1, 1);
//-> Err("…")
// assertable failed: `assertable_ne!(left, right)`
// left: `1`,
// right: `1`
assert_eq!(x.unwrap_err(), "assertable failed: `assertable_ne!(left, right)`\n left: `1`,\n right: `1`".to_string());This macro has a second form where a custom message can be provided.