Skip to content

Commit

Permalink
more refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
danieleades committed Oct 22, 2023
1 parent 97bc456 commit ac637aa
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/bin/mavlink-dump.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
8 changes: 4 additions & 4 deletions src/embedded.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ pub trait Read {
fn read_u8(&mut self) -> Result<u8, MessageReadError>;

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(())
Expand All @@ -26,8 +26,8 @@ pub trait Write {

impl<W: embedded_hal::serial::Write<u8>> 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(())
Expand Down
2 changes: 1 addition & 1 deletion tests/process_log_files.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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:?}");
Expand Down

0 comments on commit ac637aa

Please sign in to comment.