I’m having trouble trying to figure out how can I dynamically populate some sort of vector with structures of the following type, inside a loop/iterator/etc.:
struct SplitData<‘a> {
data: Vec<u8>,
split_1: Vec<&‘a u8>,
split_2: Vec<&‘a u8>,
}
In the structure above, split_1
and split_2
themselves will be vectors of references to elements already inside (and owned by?) the data
vector.
The main issue I keep facing is the infamous error “ borrowed value does not live long enough”
because the data
vectors are created inside the loop.
Could anyone shed some light into the right pattern I should implement to do this?