File tree 1 file changed +5
-5
lines changed
1 file changed +5
-5
lines changed Original file line number Diff line number Diff line change @@ -5,20 +5,20 @@ Before we wrap up this chapter, let's talk about another key trait in Rust's sta
5
5
` Sync ` is an auto trait, just like ` Send ` .\
6
6
It is automatically implemented by all types that can be safely ** shared** between threads.
7
7
8
- In order words: ` T: Sync ` means that ` &T ` is ` Send ` .
8
+ In order words: ` T ` is Sync if ` &T ` is ` Send ` .
9
9
10
- ## ` Sync ` doesn't imply ` Send `
10
+ ## ` T: Sync` doesn't imply ` T: Send`
11
11
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 ` .\
13
13
For example: ` MutexGuard ` is not ` Send ` , but it is ` Sync ` .
14
14
15
15
It isn't ` Send ` because the lock must be released on the same thread that acquired it, therefore we don't
16
16
want ` MutexGuard ` to be dropped on a different thread.\
17
17
But it is ` Sync ` , because giving a ` &MutexGuard ` to another thread has no impact on where the lock is released.
18
18
19
- ## ` Send ` doesn't imply ` Sync `
19
+ ## ` T: Send` doesn't imply ` T: Sync`
20
20
21
- The opposite is also true: ` Send ` doesn't imply ` Sync ` .\
21
+ The opposite is also true: ` T ` can be ` Send ` without being ` Sync ` .\
22
22
For example: ` RefCell<T> ` is ` Send ` (if ` T ` is ` Send ` ), but it is not ` Sync ` .
23
23
24
24
` RefCell<T> ` performs runtime borrow checking, but the counters it uses to track borrows are not thread-safe.
You can’t perform that action at this time.
0 commit comments