galvanic_assert::matchers::collection

Function all_elements_satisfy

Source
pub fn all_elements_satisfy<'a, T, I, P>(
    predicate: P,
) -> Box<dyn Fn(&'a I) -> MatchResult>
where T: Debug + 'a, &'a I: IntoIterator<Item = &'a T> + 'a, P: Fn(&'a T) -> bool + 'static,
Expand description

Matches if all elements in the asserted collection satisfy the given predicate.

An empty collection always satisfies this matcher as all (=no) element satisfies the predicate.

#Examples

use galvanic_assert::matchers::collection::*;
assert_that!(&vec![1,2,3,4,5], all_elements_satisfy(|&a| 0 <= a && a < 100));