1
0
mirror of https://github.com/google/comprehensive-rust.git synced 2025-01-05 16:10:31 +02:00

Update scoped-threads.md (#253)

Adding speaker notes explaining why scoped threads work and what borrowing rules apply.
This commit is contained in:
Igor Petruk 2023-01-23 10:56:32 +00:00 committed by GitHub
parent 77a60d4101
commit 8107a0ea2b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -31,3 +31,10 @@ fn main() {
```
[1]: https://doc.rust-lang.org/std/thread/fn.scope.html
<details>
* The reason for that is that when the `thread::scope` function completes, all the threads are guaranteed to be joined, so they can return borrowed data.
* Normal Rust borrowing rules apply: you can either borrow mutably by one thread, or immutably by any number of threads.
</details>