We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
.expect(..)
1 parent 9d1ad26 commit 87be353Copy full SHA for 87be353
std/src/thread/mod.rs
@@ -1739,11 +1739,16 @@ struct JoinInner<'scope, T> {
1739
impl<'scope, T> JoinInner<'scope, T> {
1740
fn join(mut self) -> Result<T> {
1741
self.native.join();
1742
- if let Some(packet) = Arc::get_mut(&mut self.packet) {
1743
- packet.result.get_mut().take().unwrap()
1744
- } else {
1745
- Err(Box::new("thread terminated unexpectedly"))
1746
- }
+ Arc::get_mut(&mut self.packet)
+ // FIXME(fuzzypixelz): returning an error instead of panicking here
+ // would require updating the documentation of
+ // `std::thread::Result`; currently we can return `Err` if and only
+ // if the thread had panicked.
1747
+ .expect("threads should not terminate unexpectedly")
1748
+ .result
1749
+ .get_mut()
1750
+ .take()
1751
+ .unwrap()
1752
}
1753
1754
0 commit comments