error[E0521]: borrowed data escapes outside of closure
--> src\main.rs:1539:9
|
1532 | let mut threads = Vec::with_capacity(10);
| ----------- `threads` declared here, outside of the closure body
1533 | let files_vec = Arc::clone(&files_vec);
1534 | crossbeam::scope(|spawner| {//vec_of_processes =
| ------- `spawner` is a reference that is only valid in the closure body
...
1539 | / threads.push(spawner.spawn(move |_| {
//....
}
}));//$Close threads!
| |_______^ `spawner` escapes the closure body here
Yes, the .spawn from crossbeam requires a |_| closure.
The second error message is coherent with what a crossbeam::scope is: it defines a scope (the closure's block body given to crossbeam::scope()) wherein the threads and thread handles are well defined, but outside of which they have no meaning whatsoever, since the threads will have been auto-joined by then.
That is, the very point of using crossbeam::scope is not having to deal with joining the threads, not only for the caller's convenience, but also because this auto-join property is then known by the compiler, which will then allow you to borrow outer locals inside it
So, I'd suggest to simply get rid of your threads vec altogether