Skip to content

Commit e643df0

Browse files
committed
Simplify using unwrap_or_else
1 parent 5af00d0 commit e643df0

File tree

1 file changed

+6
-10
lines changed

1 file changed

+6
-10
lines changed

src/cargo/core/compiler/job_queue.rs

+6-10
Original file line numberDiff line numberDiff line change
@@ -869,16 +869,12 @@ impl<'cfg> DrainState<'cfg> {
869869

870870
impl Drop for FinishOnDrop<'_> {
871871
fn drop(&mut self) {
872-
if let Some(result) = self.result.take() {
873-
self.messages
874-
.push(Message::Finish(self.id, Artifact::All, result));
875-
} else {
876-
self.messages.push(Message::Finish(
877-
self.id,
878-
Artifact::All,
879-
Err(format_err!("worker panicked")),
880-
));
881-
}
872+
let result = self
873+
.result
874+
.take()
875+
.unwrap_or_else(|| Err(format_err!("worker panicked")));
876+
self.messages
877+
.push(Message::Finish(self.id, Artifact::All, result));
882878
}
883879
}
884880
};

0 commit comments

Comments
 (0)