Skip to main content
InterviewHubPRO
Section Overview
Q21

Question 21 of 50

Part 3: Advanced Internals, Scale & Production Patterns (Senior / Lead)

42%
Rust Systems & Tokio (50 Qs)•Part 3: Advanced Internals, Scale & Production Patterns (Senior / Lead)

What are the `Send` and `Sync` marker traits in Rust Concurrency?

senior LevelrustAdvanced Internals

In Simple Words: The foundation of Rust's "Fearless Concurrency":

  • Send: Indicates that ownership of the type can be safely transferred across thread boundaries.
    • Almost all types are Send. Exception: Rc<T> is NOT Send because non-atomic reference count updates cause race conditions!
  • Sync: Indicates that it is safe to share references to the type across multiple threads (&T is Send).
    • A type is Sync if and only if &T is thread-safe. RefCell<T> is NOT Sync; Mutex<T> is Sync.
  • Automatically implemented by the compiler if all struct members are Send and Sync.