File tree Expand file tree Collapse file tree 1 file changed +5
-5
lines changed Expand file tree Collapse file tree 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
55` Sync ` is an auto trait, just like ` Send ` .\
66It 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 ` .\
1313For example: ` MutexGuard ` is not ` Send ` , but it is ` Sync ` .
1414
1515It isn't ` Send ` because the lock must be released on the same thread that acquired it, therefore we don't
1616want ` MutexGuard ` to be dropped on a different thread.\
1717But 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 ` .\
2222For 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.
You can’t perform that action at this time.
0 commit comments