Skip to content

Commit

Permalink
adc: hardware: replace .unwraps() around setup done queue with .expect()
Browse files Browse the repository at this point in the history
While .expect() still means panicking it is considerd a better kind of
panicking than .unwrap().

Signed-off-by: Leonard Göhrs <l.goehrs@pengutronix.de>
  • Loading branch information
hnez committed Oct 6, 2023
1 parent c4ef644 commit 0738860
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions src/adc/iio/hardware.rs
Original file line number Diff line number Diff line change
Expand Up @@ -362,7 +362,9 @@ impl IioThread {
Err(e) => {
// Can not fail in practice as the queue is known to be empty
// at this point.
thread_res_tx.try_send(Err(e)).unwrap();
thread_res_tx
.try_send(Err(e))
.expect("Failed to signal ADC setup error due to full queue");
return Ok(());
}
};
Expand All @@ -385,7 +387,8 @@ impl IioThread {
if let Some((_, tx)) = signal_ready.take() {
// Can not fail in practice as the queue is only .take()n
// once and thus known to be empty.
tx.try_send(Err(Error::new(e))).unwrap();
tx.try_send(Err(Error::new(e)))
.expect("Failed to signal ADC setup error due to full queue");
}

break;
Expand Down Expand Up @@ -415,7 +418,8 @@ impl IioThread {
if let Some((content, tx)) = signal_ready.take() {
// Can not fail in practice as the queue is only .take()n
// once and thus known to be empty.
tx.try_send(Ok(content)).unwrap();
tx.try_send(Ok(content))
.expect("Failed to signal ADC setup completion due to full queue");
}
}

Expand Down

0 comments on commit 0738860

Please sign in to comment.