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