Skip to content

Commit 68aa1e8

Browse files
fuzzypixelzgitbot
authored and
gitbot
committed
Use .expect(..) instead
1 parent a5cf779 commit 68aa1e8

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

std/src/thread/mod.rs

+10-5
Original file line numberDiff line numberDiff line change
@@ -1739,11 +1739,16 @@ struct JoinInner<'scope, T> {
17391739
impl<'scope, T> JoinInner<'scope, T> {
17401740
fn join(mut self) -> Result<T> {
17411741
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-
}
1742+
Arc::get_mut(&mut self.packet)
1743+
// FIXME(fuzzypixelz): returning an error instead of panicking here
1744+
// would require updating the documentation of
1745+
// `std::thread::Result`; currently we can return `Err` if and only
1746+
// if the thread had panicked.
1747+
.expect("threads should not terminate unexpectedly")
1748+
.result
1749+
.get_mut()
1750+
.take()
1751+
.unwrap()
17471752
}
17481753
}
17491754

0 commit comments

Comments
 (0)