Skip to content

Commit bb98043

Browse files
Clean up radio error match.
We can nest it as a single pattern.
1 parent 4c583ac commit bb98043

File tree

2 files changed

+18
-10
lines changed

2 files changed

+18
-10
lines changed

nrf52-code/boards/dk-solution/src/radio.rs

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -454,11 +454,15 @@ impl<'d> Radio<'d> {
454454
// Check if either receive is done or timeout occured
455455
loop {
456456
match recv.is_done() {
457-
Ok(crc) => break Ok(crc),
458-
Err(err) => match err {
459-
nb::Error::Other(crc) => break Err(Error::Crc(crc)),
460-
nb::Error::WouldBlock => (),
461-
},
457+
Ok(crc) => {
458+
break Ok(crc);
459+
}
460+
Err(nb::Error::Other(crc)) => {
461+
break Err(Error::Crc(crc));
462+
}
463+
Err(nb::Error::WouldBlock) => {
464+
// do nothing
465+
}
462466
}
463467

464468
if timer.reset_if_finished() {

nrf52-code/boards/dk/src/radio.rs

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -454,11 +454,15 @@ impl<'d> Radio<'d> {
454454
// Check if either receive is done or timeout occured
455455
loop {
456456
match recv.is_done() {
457-
Ok(crc) => break Ok(crc),
458-
Err(err) => match err {
459-
nb::Error::Other(crc) => break Err(Error::Crc(crc)),
460-
nb::Error::WouldBlock => (),
461-
},
457+
Ok(crc) => {
458+
break Ok(crc);
459+
}
460+
Err(nb::Error::Other(crc)) => {
461+
break Err(Error::Crc(crc));
462+
}
463+
Err(nb::Error::WouldBlock) => {
464+
// do nothing
465+
}
462466
}
463467

464468
if timer.reset_if_finished() {

0 commit comments

Comments
 (0)