book
book copied to clipboard
Wrong phrasing in subsection "Using move Closures with Threads" of section 16.1
- In subsection "Using move Closures with Threads" of section 16.1 (link: https://doc.rust-lang.org/book/ch16-01-threads.html#using-move-closures-with-threads), the following paragraph:
Notice in Listing 16-1 that the closure we pass to thread::spawn takes no arguments: we’re not using any data from the main thread in the spawned thread’s code. To use data from the main thread in the spawned thread, the spawned thread’s closure must capture the values it needs. Listing 16-3 shows an attempt to create a vector in the main thread and use it in the spawned thread. However, this won’t work yet, as you’ll see in a moment.
- should be corrected to:
In Listing 16-1 the closure we pass to thread::spawn captures no values from the main thread: we’re not using any data from the main thread in the spawned thread’s code. To use data from the main thread in the spawned thread, the spawned thread’s closure must capture the values it needs. Listing 16-3 shows an attempt to create a vector in the main thread and use it in the spawned thread. However, this won’t work yet, as you’ll see in a moment.