Sometimes, when a program operates on multiple threads, the current version of settings and many more are available to the threads as a single point of truth. Sharing a state between threads is straightforward in Rust—as long as the variable is immutable and the types are marked as safe to share. In order to mark types as thread-safe, it's important that the implementation makes sure that accessing the information can be done without any kind of inconsistency occurring.
Rust uses two marker traits—Send and Sync—to manage these options. Let's see how.