Skip to content

Commit dad731c

Browse files
committed
Rollup merge of rust-lang#44962 - shepmaster:no-ignore-result, r=steveklabnik
Don't encourage people to ignore threading errors in the docs
2 parents d7acd29 + b5b7666 commit dad731c

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

src/libstd/thread/mod.rs

+7-5
Original file line numberDiff line numberDiff line change
@@ -485,15 +485,17 @@ impl Builder {
485485
/// let (tx, rx) = channel();
486486
///
487487
/// let sender = thread::spawn(move || {
488-
/// let _ = tx.send("Hello, thread".to_owned());
488+
/// tx.send("Hello, thread".to_owned())
489+
/// .expect("Unable to send on channel");
489490
/// });
490491
///
491492
/// let receiver = thread::spawn(move || {
492-
/// println!("{}", rx.recv().unwrap());
493+
/// let value = rx.recv().expect("Unable to receive from channel");
494+
/// println!("{}", value);
493495
/// });
494496
///
495-
/// let _ = sender.join();
496-
/// let _ = receiver.join();
497+
/// sender.join().expect("The sender thread has panicked");
498+
/// receiver.join().expect("The receiver thread has panicked");
497499
/// ```
498500
///
499501
/// A thread can also return a value through its [`JoinHandle`], you can use
@@ -1192,7 +1194,7 @@ impl<T> JoinInner<T> {
11921194
/// });
11931195
/// });
11941196
///
1195-
/// let _ = original_thread.join();
1197+
/// original_thread.join().expect("The thread being joined has panicked");
11961198
/// println!("Original thread is joined.");
11971199
///
11981200
/// // We make sure that the new thread has time to run, before the main

0 commit comments

Comments
 (0)