pub fn scoped<'a, T, F>(f: F) -> JoinGuard<'a, T> where T: Send + 'a, F: FnOnce() -> T, F: Send + 'a
: memory unsafe if destructor is avoided, see #24292
Spawns a new scoped thread, returning a
JoinGuard for it.
The join guard can be used to explicitly join the child thread (via
Result<T>, or it will implicitly join the child
upon being dropped. Because the child thread may refer to data on the
current thread's stack (hence the "scoped" name), it cannot be detached;
it must be joined before the relevant stack frame is popped. See the
module documentation for additional details.
Panics if the OS fails to create a thread; use
to recover from such errors.