Skip to content

Commit

Permalink
Simplify using unwrap_or_else
Browse files Browse the repository at this point in the history
  • Loading branch information
bjorn3 committed Nov 9, 2020
1 parent 5af00d0 commit e643df0
Showing 1 changed file with 6 additions and 10 deletions.
16 changes: 6 additions & 10 deletions src/cargo/core/compiler/job_queue.rs
Original file line number Diff line number Diff line change
Expand Up @@ -869,16 +869,12 @@ impl<'cfg> DrainState<'cfg> {

impl Drop for FinishOnDrop<'_> {
fn drop(&mut self) {
if let Some(result) = self.result.take() {
self.messages
.push(Message::Finish(self.id, Artifact::All, result));
} else {
self.messages.push(Message::Finish(
self.id,
Artifact::All,
Err(format_err!("worker panicked")),
));
}
let result = self
.result
.take()
.unwrap_or_else(|| Err(format_err!("worker panicked")));
self.messages
.push(Message::Finish(self.id, Artifact::All, result));
}
}
};
Expand Down

0 comments on commit e643df0

Please sign in to comment.