Skip to main content

each

Function each 

Source
pub fn each<MatcherT>(inner: MatcherT) -> EachMatcher<MatcherT>
Expand description

Matches a container all of whose elements are matched by the matcher inner.

T must implement IntoIterator. This includes &Vec, arrays, and slices.

let value = vec![1, 2, 3];
verify_that!(value, each(gt(&0)))?;  // Passes
let array_value = [1, 2, 3];
verify_that!(array_value, each(gt(0)))?;  // Passes
let slice_value = &[1, 2, 3];
verify_that!(slice_value, each(gt(&0)))?;  // Passes
verify_that!(value, each(lt(&2)))?;  // Fails: 2 and 3 are not less than 2

let value: HashSet<i32> = [1, 2, 3].into();
verify_that!(value, each(gt(&0)))?;  // Passes