|
|
|
|
|
by steveklabnik
1364 days ago
|
|
> Are all Rust data types mt-safe? Yes, but not in the sense you probably think, given your second sentence: > Does unsafe mode provide faster unprotected versions if you need those? Some data types can be safely shared between threads, and some cannot. Rust checks at compile time if you try and use a non-thread safe data structure from multiple threads, and if you do, will give you an error. So in that sense, all of them are safe, yes. You don’t use unsafe to get access to non-thread safe data structures, you may have both kinds, and the compiler checks you use them correctly. |
|
Is there any provision for building your own thread-safe types (e.g. a structure composed of other types) out of non-thread-safe types and mutexes, and if so how does that work in terms of compile-time errors ?