Hi
I'm trying to pass a reference to a Vec<Vec<u8>> into a thread from a struct, but I can't get that to work. I've tried the clone trait, referencing to the array, creating a new variable and referencing to that instead, cloning the whole array. But I keep getting compiler errors.
borrowed data escapes outside of associated function
`self` escapes the associated function body here
thread::spawn(move || {
^^^^^^^
|
value moved into closure here, in previous iteration of loop
value used here after move
pub fn step_multit(&mut self)
{
let mut th: Vec<JoinHandle<()>> = Vec::with_capacity((self.rows * self.blocks) as usize);
for r in 0..self.rows {
for b in 0..self.blocks {
th.push(
thread::spawn(move || {
let r = r.clone();
let b = b.clone();// These ones copied over fine
// ...
})
);
}
}
for t in th {
t.join().unwrap();
}
}
}
}