macro_rules! assert_all_eq_x {
($iter:expr, $x:expr $(,)?) => { ... };
($iter:expr, $x:expr, $($message:tt)+) => { ... };
}Expand description
Assert all elements of an iteratable are equal to a value.
Pseudocode:
iter ∀ = x
-
If true, return
(). -
Otherwise, call
panic!with a message and the values of the expressions with their debug representations.
§Examples
use assertables::*;
let a = [1, 1];
let b = 1;
assert_all_eq_x!(a.iter(), b);
// This will panic
let a = [1, 2];
let b = 1;
assert_all_eq_x!(a.iter(), b);
// assertion failed: `assert_all_eq_x!(iter, x)`
// https://docs.rs/assertables/…/assertables/macro.assert_all_eq_x.html
// iter label: `a.iter()`,
// iter debug: `Iter([1, 2])`,
// x label: `&b`,\n",
// x debug: `1`",This implementation uses ::std::iter::Iterator.