2 ms·
Right. It just affects other decisions about the language, like the type of static items. In a purely single–threaded program it would be ok if statics weren’t
by db48x 4y ago
Right. It just affects other decisions about the language, like the type of static items. In a purely single–threaded program it would be ok if statics weren’t Sync, but it would be a lot of work for the compiler to verify that. And since every program needs tests anyway, it might as well always require them to be Sync and then it doesn’t have to check.
- steveklabnik 4y agoTotally. I take a slightly different view in the statics thing; like a static means you want something to be available across threads. So by using a static, you’re opening yourself to that possibility. If you want something global to a thread, use thread local storage, and Rust will allow you to use stuff that’s not okay if multiple threads were involved. It’s about expressing your intent correctly.
- brundolf 4y agoTIL thread local storage!