Skip to content

Send and Sync

Category: Safety in languages · Status: stub · Lessons: chapter 02, Shared state

One line: Rust's two marker traits: a Send value may move to another thread, a Sync value may be shared with one by reference, and the compiler checks both.

Also called: Sendable.

How it connects

flowchart LR
  n_data_race["Data race"]
  n_data_race_freedom["Data-race freedom by construction"]
  n_send_and_sync["Send and Sync"]
  n_data_race_freedom -->|uses| n_send_and_sync
  n_send_and_sync -->|prevents| n_data_race
  classDef center stroke-width:3px
  class n_send_and_sync center
  classDef outside stroke-dasharray: 4 3
  class n_data_race,n_data_race_freedom outside

In each language

Rust Send and Sync are unsafe auto traits; Rc is not Send because its reference count is not atomic, while Arc is
Swift Sendable plays the same part: a type whose values can cross concurrent contexts without risk of data races

Where to read more