]> git.proxmox.com Git - rustc.git/blobdiff - src/doc/rust-by-example/src/std_misc/threads/testcase_mapreduce.md
New upstream version 1.65.0+dfsg1
[rustc.git] / src / doc / rust-by-example / src / std_misc / threads / testcase_mapreduce.md
index 28075164fca7045ff319785417411a8fe4a12fec..ee25b1661c5eadd2282e9d7ef10bdc3143e0002c 100644 (file)
@@ -17,9 +17,11 @@ its tiny block of digits, and subsequently we will sum the intermediate sums pro
 thread.
 
 Note that, although we're passing references across thread boundaries, Rust understands that we're
-only passing read-only references, and that thus no unsafety or data races can occur. Because
-we're `move`-ing the data segments into the thread, Rust will also ensure the data is kept alive
-until the threads exit, so no dangling pointers occur.
+only passing read-only references, and that thus no unsafety or data races can occur. Also because
+the references we're passing have `'static` lifetimes, Rust understands that our data won't be
+destroyed while these threads are still running. (When you need to share non-`static` data between
+threads, you can use a smart pointer like `Arc` to keep the data alive and avoid non-`static`
+lifetimes.)
 
 ```rust,editable
 use std::thread;