3 ms·
Doing this using a destructor, or worse in straight-line code, turns out to be unsound. So it's more than marginally useful for those familiar with Chesterton's
by firstlink 4y ago
Doing this using a destructor, or worse in straight-line code, turns out to be unsound. So it's more than marginally useful for those familiar with Chesterton's fence.
- cpuguy83 4y agoI didn't say it was useless, only that its use is highly limited to a very specific case, namely "do a bunch of things at the same time and block until completion".
- firstlink 4y agoIf the scope is the lifetime of the program, then it hardly makes a difference. Note that rust programs exit upon return from main anyways.
- cpuguy83 4y agoThis is the point of lifetimes. Everything has a lifetime whether or not it is annotated. Sometimes the compiler doesn't know what the lifetime of an object is, particularly in relation to other objects. If you can scope something to main() then that is a 'static lifetime and there is no need for a scoped thread for it.