pub fn recoverable_spawn<F>(f: F) -> JoinHandle<()>Expand description
Spawns a new thread to run the provided function f in a recoverable manner.
If the function f panics during execution, the panic will be caught, and the thread
will terminate without crashing the entire program.
§Parameters
f: A function of typeFto be executed in the spawned thread. It must implementFn(),Send,Sync, and'statictraits.Fn(): The function is callable with no arguments and no return value.Send: The function can be safely transferred across thread boundaries.Sync: The function can be shared across threads safely.'static: The function does not contain references to non-static data (i.e., data that lives beyond the function’s scope).
§Returns
- A
JoinHandle<()>representing the spawned thread. The thread can be joined later to wait for its completion.
§Panics
- This function itself will not panic, but the function
fcould panic during execution. The panic will be caught, preventing the program from crashing.