galvanic_assert::matchers::collection

Function some_elements_satisfy

Source
pub fn some_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(&T) -> bool + 'static,
Expand description

Matches if at least one element in the asserted collection satisfy the given predicate.

An empty collection never satisfies this matcher as no element satisfies the predicate.

#Examples

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