diff --git a/src/bin/mavlink-dump.rs b/src/bin/mavlink-dump.rs index 2f262af9f9..9d30e84d40 100644 --- a/src/bin/mavlink-dump.rs +++ b/src/bin/mavlink-dump.rs @@ -49,7 +49,7 @@ fn main() { println!("received: {msg:?}"); } Err(MessageReadError::Io(e)) => { - if let std::io::ErrorKind::WouldBlock = e.kind() { + if e.kind() == std::io::ErrorKind::WouldBlock { //no messages currently available to receive -- wait a while thread::sleep(Duration::from_secs(1)); continue; diff --git a/src/embedded.rs b/src/embedded.rs index 64138a5b14..574ae2b826 100644 --- a/src/embedded.rs +++ b/src/embedded.rs @@ -5,8 +5,8 @@ pub trait Read { fn read_u8(&mut self) -> Result; fn read_exact(&mut self, buf: &mut [u8]) -> Result<(), MessageReadError> { - for i in 0..buf.len() { - buf[i] = self.read_u8()?; + for byte in buf { + *byte = self.read_u8()?; } Ok(()) @@ -26,8 +26,8 @@ pub trait Write { impl> Write for W { fn write_all(&mut self, buf: &[u8]) -> Result<(), MessageWriteError> { - for i in 0..buf.len() { - nb::block!(self.write(buf[i])).map_err(|_| MessageWriteError::Io)?; + for byte in buf { + nb::block!(self.write(*byte)).map_err(|_| MessageWriteError::Io)?; } Ok(()) diff --git a/tests/process_log_files.rs b/tests/process_log_files.rs index a38665fd8f..0bf71544f8 100644 --- a/tests/process_log_files.rs +++ b/tests/process_log_files.rs @@ -36,7 +36,7 @@ mod process_files { counter += 1; } Err(MessageReadError::Io(e)) => { - if let std::io::ErrorKind::WouldBlock = e.kind() { + if e.kind() == std::io::ErrorKind::WouldBlock { continue; } else { println!("recv error: {e:?}");