Send and Sync
- A type is Send if it is safe to send it to another thread.
- A type is Sync if it is safe to share between threads (T is Sync if and only if &T is Send).
- raw pointers are neither Send nor Sync (because they have no safety guards).
- UnsafeCell isn’t Sync (and therefore Cell and RefCell aren’t).
- Rc isn’t Send or Sync (because the refcount is shared and unsynchronized).
Types that aren’t automatically derived can simply implement them if desired:
1 | struct MyBox(*mut u8); |
one can also unimplement Send and Sync:
1 |
|