pub fn every<'a, PosOut, NegOut, IntoIter>(
matcher: impl Fn() -> Matcher<'a, IntoIter::Item, PosOut, NegOut> + 'a
) -> Matcher<'a, IntoIter, Vec<PosOut>, Vec<NegOut>>where
IntoIter: Debug + IntoIterator + 'a,
PosOut: 'a,
NegOut: 'a,
Expand description
Succeeds when the matcher succeeds for every element of the actual value.
This accepts a closure which returns a matcher for every element in the collection.
Examples
Expect every element to be Some(_)
, unwrapping into a vec of strings.
use xpct::{be_some, every, expect};
let items = vec![Some("foo"), Some("bar")];
let output: Vec<&str> = expect!(items)
.to(every(be_some))
.into_inner();
Expect every element to be in the range 20..30
.
use xpct::{be_in, every, expect};
expect!(vec![20, 25]).to(every(|| be_in(20..30)));