I have a vector of lots of Point structures that I wish to iterate constantly in batches.
For example
loop {
let mut all_points : Vec<Point> = points;
for chunk in all_points.chunks_mut(100) {
for point in chunk.to_owned() {
}
}
}
This works ok but I would like to able to access the point as a mutable
if I change the above to
loop {
let mut all_points : Vec<Point> = points;
for chunk in all_points.chunks_mut(100) {
for point in chunk.iter_mut() {
}
}
}
I get the error
for chunk in all_points.chunks_mut(100) {
| ^^^^^^^^^^------------------------------
| |
| borrowed value does not live long enough
| argument requires that `all_points` is borrowed for `'static`
How can I work around this ?
Thanks