Macro assertables::assure_fn_eq [−][src]
macro_rules! assure_fn_eq { ($function:path, $left:expr, $right:expr $(,)?) => { ... }; ($function:path, $left:expr, $right:expr, $($arg:tt)+) => { ... }; }
Expand description
Assure one function output is equal to another function output.
-
When true, return
Ok(true). -
When false, return
Ok(false). -
Otherwise, return
Errwith a message and the values of the expressions with their debug representations.
Examples
let x: Result<bool, &str> = assure_fn_eq!(i32::abs, 1 as i32, -1 as i32); //-> Ok(true)
let x: Result<bool, &str> = assure_fn_eq!(i32::abs, 1 as i32, -2 as i32); //-> Ok(false)
This macro has a second form where a custom message can be provided.