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

Function pair_with_slice

utils/src/iter.rs:23–33  ·  view source on GitHub ↗

Maps supplied iterator and attempts to pair each item with an item from the slice which has provided index. Returns `Err` containing an invalid index in case slice length is exceeded.

(
    iter: I,
    pair_with: &'pairs [P],
)

Source from the content-addressed store, hash-verified

21/// Maps supplied iterator and attempts to pair each item with an item from the slice which has provided index.
22/// Returns `Err` containing an invalid index in case slice length is exceeded.
23pub fn pair_with_slice<'iter, 'pairs, I, Item, P>(
24 iter: I,
25 pair_with: &'pairs [P],
26) -> impl Iterator<Item = Result<(&'pairs P, Item), IndexIsOutOfBounds>> + 'iter
27where
28 'pairs: 'iter,
29 I: IntoIterator<Item = (usize, Item)> + 'iter,
30 Item: 'iter,
31{
32 try_pair_with_slice(iter.into_iter().map(Ok), pair_with)
33}
34
35/// Ensures that the given iterator satisfies provided validator for each item.
36/// In case of an error, `Err(V::Failure)` will be emitted.

Callers 2

newMethod · 0.85
newMethod · 0.85

Calls 3

try_pair_with_sliceFunction · 0.85
mapMethod · 0.80
into_iterMethod · 0.45

Tested by

no test coverage detected