3 ms·
Rust basically gives the compiler understanding of unique_ptr and prevents you from using it after you’ve moved it.
by saagarjha 6y ago
Rust basically gives the compiler understanding of unique_ptr and prevents you from using it after you’ve moved it.
- Ididntdothis 6y agoWould you have to keep track of these threads in Rust? I have done a lot of desktop development where you have to be aware of what happens during shutdown. Seems a lot of server guys write their code under the assumption that it will never shut down.
- firethief 6y agoThe answer to this question is the same for any language without a heavy runtime. You can choose to join the worker thread, detach it, or kill it.
- pornel 6y agoYou would need to add `thread.join()` at the end of main, or have some RAII guard that does it for you. In practice that's probably optional, because the heap and all resources are usually torn down with the process anyway. Important things, like saving data or committing transactions, shouldn't be done in destructors.
- deleted 6y ago[deleted]