pub fn iter_map<'a, In, Out, IntoIter>(
func: impl Fn(In) -> Out + 'a
) -> Matcher<'a, IntoIter, IterMap<'a, In, Out, IntoIter::IntoIter>>where
In: 'a,
Out: 'a,
IntoIter: IntoIterator<Item = In> + 'a,
Expand description
Infallibly map each value of an iterator by applying a function to it.
This does the same thing as Assertion::iter_map
.
This matcher always succeeds, even when negated. Therefore negating it has no effect.
Examples
use xpct::{be_some, every, expect, iter_map};
let items = vec![Some("foo"), Some("bar")];
let output: Vec<&str> = expect!(&items)
.to(iter_map(Option::as_deref))
.to(every(be_some))
.into_inner();