assert_any

Macro assert_any 

Source
macro_rules! assert_any {
    ($collection:expr, $predicate:expr $(,)?) => { ... };
    ($collection:expr, $predicate:expr, $($message:tt)+) => { ... };
}
Expand description

Assert every element of the iterator matches a predicate.

Pseudocode:
collection into 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, 3];
assert_any!(a.into_iter(), |x: i8| x > 0);

// This will panic
let a = [1, 2, 3];
assert_any!(a.into_iter(), |x: i8| x > 3);
// assertion failed: `assert_any!(collection, predicate)`
// https://docs.rs/assertables/…/assertables/macro.assert_any.html
//  collection label: `a.into_iter()`,
//  collection debug: `IntoIter([1, 2, 3])`,
//         predicate: `|x: i8| x > 3`

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

§Module macros