Skip to content

Commit fb19005

Browse files
Clarify Send-Sync relationship (#237)
1 parent cc0092b commit fb19005

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

book/src/07_threads/14_sync.md

+5-5
Original file line numberDiff line numberDiff line change
@@ -5,20 +5,20 @@ Before we wrap up this chapter, let's talk about another key trait in Rust's sta
55
`Sync` is an auto trait, just like `Send`.\
66
It is automatically implemented by all types that can be safely **shared** between threads.
77

8-
In order words: `T: Sync` means that `&T` is `Send`.
8+
In order words: `T` is Sync if `&T` is `Send`.
99

10-
## `Sync` doesn't imply `Send`
10+
## `T: Sync` doesn't imply `T: Send`
1111

12-
It's important to note that `Sync` doesn't imply `Send`.\
12+
It's important to note that `T` can be `Sync` without being `Send`.\
1313
For example: `MutexGuard` is not `Send`, but it is `Sync`.
1414

1515
It isn't `Send` because the lock must be released on the same thread that acquired it, therefore we don't
1616
want `MutexGuard` to be dropped on a different thread.\
1717
But it is `Sync`, because giving a `&MutexGuard` to another thread has no impact on where the lock is released.
1818

19-
## `Send` doesn't imply `Sync`
19+
## `T: Send` doesn't imply `T: Sync`
2020

21-
The opposite is also true: `Send` doesn't imply `Sync`.\
21+
The opposite is also true: `T` can be `Send` without being `Sync`.\
2222
For example: `RefCell<T>` is `Send` (if `T` is `Send`), but it is not `Sync`.
2323

2424
`RefCell<T>` performs runtime borrow checking, but the counters it uses to track borrows are not thread-safe.

0 commit comments

Comments
 (0)