Skip to main content

assert_any_eq_x

Macro assert_any_eq_x 

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

Assert any element of an iterable is 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, 2];
let b = 1;
assert_any_eq_x!(a.iter(), b);

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

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

§Module macros