Skip to main content

assert_all_ne_x

Macro assert_all_ne_x 

Source
macro_rules! assert_all_ne_x {
    ($iter:expr, $x:expr $(,)?) => { ... };
    ($iter:expr, $x:expr, $($message:tt)+) => { ... };
}
Expand description

Assert all elements of an iteratable match a x.

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, 2];
let b = 3;
assert_all_ne_x!(a.iter(), b);

// This will panic
let a = [1, 2];
let b = 1;
assert_all_ne_x!(a.iter(), b);
// assertion failed: `assert_all_ne_x!(iter, x)`
// https://docs.rs/assertables/…/assertables/macro.assert_all_ne_x.html
//  iter label: `a.iter()`,
//  iter debug: `Iter([1, 2])`,
//  x label: `b`,\n",
//  x debug: `1`"

This implementation uses ::std::iter::Iterator.

§Module macros