The Rust language doesn't know anything about locking, or even threads.
The thread safety is built using Send/Sync traits, which libraries for threading and synchronization primitives, atomics, etc. implement accordingly.
The thread safety is built using Send/Sync traits, which libraries for threading and synchronization primitives, atomics, etc. implement accordingly.
Languages like C++ and D treat this as a library design challenge, not a core language feature. Look at std::lock_guard, for example.