Function xpct::iter_try_map
source · pub fn iter_try_map<'a, In, Out, IntoIter>(
func: impl Fn(In) -> Result<Out> + 'a
) -> Matcher<'a, IntoIter, Vec<Out>>where
In: 'a,
Out: 'a,
IntoIter: IntoIterator<Item = In> + 'a,
Expand description
Fallibly map each value of an iterator by applying a function to it.
This does the same thing as Assertion::iter_try_map
.
This matcher always succeeds as long as func
returns Ok
, even when negated. Therefore
negating it has no effect.
Examples
use xpct::{expect, iter_try_map, consist_of};
let small_integers: [u64; 2] = [41, 57];
expect!(small_integers)
.to(iter_try_map(|value| Ok(u32::try_from(value)?)))
.to(consist_of([41u32, 57u32]));