chunks
returns an iterator that produces slices, so chunk.clone()
is a slice. Therefore, this loop:
for chunk in entries.chunks(entries.len() / 5) {
t_paths.push(chunk.clone());
}
inserts slices that reference entries
into t_paths
; it should be
for chunk in entries.chunks(entries.len() / 5) {
t_paths.push(chunk.to_vec());
}
instead, if you intend to clone the paths. (Alternatively, you could use scoped threads to be able to reference entries
from the threads.)
for path in t_path {
// ...
}
drop(t_path);
t_path
is consumed by the loop, so the drop(t_path)
should be removed.
// for h in thread_handles {
// h.join().unwrap();
// }
let meh: i32 = thread_handles[0].join().unwrap();
The loop would work, but this doesn't. thread_handles[0]
returns a (possibly mutable) reference to the thread; you need to take ownership if you intend to join:
let mut threads = thread_handles.into_iter();
// takes ownership of the first thread
let meh = threads.next().unwrap().join().unwrap();
// the rest of the threads should probably still be joined
for thread in threads {
thread.join().unwrap();
}
These will fix the compilation errors.