macro_rules! assert_any {
($iter:expr, $predicate:expr $(,)?) => { ... };
($iter:expr, $predicate:expr, $($message:tt)+) => { ... };
}Expand description
Assert any element of an iterable matches a predicate.
Pseudocode:
iter ∃ predicate
-
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];
assert_any!(a.iter(), |&x| x > 0);
// This will panic
let a = [1, 2];
assert_any!(a.iter(), |&x| x > 3);
// assertion failed: `assert_any!(iter, predicate)`
// https://docs.rs/assertables/…/assertables/macro.assert_any.html
// iter label: `a.iter()`,
// iter debug: `Iter([1, 2])`,
// predicate: `|&x| x > 3`This implementation uses ::std::iter::Iterator.