Rust Systems & Tokio (50 Qs)•Part 3: Advanced Internals, Scale & Production Patterns (Senior / Lead)
Concurrency in Rust: `Send` and `Sync` Marker Traits.
senior LevelrustAdvanced Internals
In Simple Words: Rust guarantees "Fearless Concurrency" via two auto-implemented marker traits:
Send: Indicates ownership of the type can be safely transferred across thread boundaries (T: Send). Almost all Rust types areSend, except types with raw pointers or non-atomic reference counts (Rc<T>).Sync: Indicates it is safe to share references to this type between multiple threads concurrently (&T: Send). A typeTisSyncif and only if&TisSend.