I have a two vectors:
-
a is a
Vec<usize>
and eachusize
corresponds to the number of items that I need to read from -
b which is a
Vec<u8>
that contains the data
So here's what I want to do:
- Get the next n characters to read from a
- Read n characters from b
- Increment reading position of b by 1 (i.e to skip a character)
- Get the next n characters to read from a
... Until I reach the end of a
Though it is super simple to use a simple loop to read the data and return from it, but what I want to do, should look something like:
let extracted_vec: Vec<Vec<u8>> = a.into_iter().map(|size| {
vec![b.take(size).collect::<u8>()]
}).collect();
The snag here is: I want to consume the elements of a and b at the same time, which, to say, is kind of like a conditional zip()
.
Any suggestions?