Use handle the same way in similarly structured examples
This commit is contained in:
parent
aca2057ed5
commit
d112274fcb
1 changed files with 5 additions and 3 deletions
|
|
@ -343,12 +343,14 @@ threads as a simple isolation mechanism:
|
|||
```rust
|
||||
use std::thread;
|
||||
|
||||
let result = thread::spawn(move || {
|
||||
let handle = thread::spawn(move || {
|
||||
panic!("oops!");
|
||||
}).join();
|
||||
});
|
||||
|
||||
let result = handle.join();
|
||||
|
||||
assert!(result.is_err());
|
||||
```
|
||||
|
||||
Our `Thread` gives us a `Result` back, which allows us to check if the thread
|
||||
`Thread.join()` gives us a `Result` back, which allows us to check if the thread
|
||||
has panicked or not.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue