MCPcopy Create free account
hub / github.com/docknetwork/crypto / pair_valid_items_with_slice

Function pair_valid_items_with_slice

utils/src/iter.rs:48–64  ·  view source on GitHub ↗

Maps supplied iterator and attempts to pair each successfully validated item with a corresponding item from the slice. Validation errors will be propagated without looking at them.

(
    iter: I,
    validator: V,
    pair_with: &'pairs [Pair],
)

Source from the content-addressed store, hash-verified

46/// with a corresponding item from the slice.
47/// Validation errors will be propagated without looking at them.
48pub fn pair_valid_items_with_slice<'iter, 'pairs, I, Item, Pair, E, V>(
49 iter: I,
50 validator: V,
51 pair_with: &'pairs [Pair],
52) -> impl Iterator<Item = Result<(&'pairs Pair, Item), E>> + 'iter
53where
54 'pairs: 'iter,
55 I: IntoIterator<Item = (usize, Item)> + 'iter,
56 Item: 'iter,
57 V: SeqValidator<(usize, Item)> + 'iter,
58 E: From<IndexIsOutOfBounds> + From<V::Failure> + 'iter,
59{
60 try_pair_with_slice(
61 validate(iter, validator).map(|res| res.map_err(E::from)),
62 pair_with,
63 )
64}
65
66/// Ensures that the given iterator satisfies provided validator for each item.
67/// The supplied option will be modified to `V::Failure` in case of failure, and iteration will be aborted.

Callers 2

unblindMethod · 0.85

Calls 3

try_pair_with_sliceFunction · 0.85
mapMethod · 0.80
validateFunction · 0.70

Tested by

no test coverage detected